<!-- 博客 - 页面布局 > 上中下 -->



<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=dark>
<!-- 博客 - 导航栏上方 -->


<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/blog/img/fluid.png">
  <link rel="icon" href="/blog/img/icon/dw.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Memory">
  <meta name="keywords" content="">

  
    <meta name="description" content="每天进步一点点，见证编程能力的蜕变过程">
<meta property="og:type" content="article">
<meta property="og:title" content="小程序开发经验分享：踩坑指南与技巧总结">
<meta property="og:url" content="https://test.atomgit.net/blog/2023/07/30/%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%BC%80%E5%8F%91%E7%BB%8F%E9%AA%8C%E5%88%86%E4%BA%AB%EF%BC%9A%E8%B8%A9%E5%9D%91%E6%8C%87%E5%8D%97%E4%B8%8E%E6%8A%80%E5%B7%A7%E6%80%BB%E7%BB%93/index.html">
<meta property="og:site_name" content="Memory&#39;s blog">
<meta property="og:description" content="每天进步一点点，见证编程能力的蜕变过程">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://test.atomgit.net/blog/img/artical/grass20240808.jpg">
<meta property="article:published_time" content="2023-07-30T10:42:15.000Z">
<meta property="article:modified_time" content="2025-07-03T15:15:32.000Z">
<meta property="article:author" content="Memory">
<meta property="article:tag" content="经验">
<meta property="article:tag" content="项目">
<meta property="article:tag" content="小程序">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://test.atomgit.net/blog/img/artical/grass20240808.jpg">
  
  
  
  <title>小程序开发经验分享：踩坑指南与技巧总结 - Memory&#39;s blog</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/blog/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/blog/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/blog/css/highlight-dark.css" />
  



  
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">



  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"test.atomgit.net","root":"/blog/","version":"1.9.4","typing":{"enable":true,"typeSpeed":100,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":false,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":true,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"appId":"T1hUHH9Ks1ggG9DBE3HgUPpV-gzGzoHsz","appKey":"XFkgzzvzNo3J3uNCbBiSOFKc","server_url":"https://t1huhh9k.lc-cn-n1-shared.com","path":"window.location.pathname","ignore_local":false}},"search_path":"/blog/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/blog/js/utils.js" ></script>
  <script  src="/blog/js/color-schema.js" ></script>
  

  

  

  

  

  

  

  



  
<meta name="generator" content="Hexo 5.4.2"></head>

<body>
  

  <header>
    <!-- 博客 - 导航栏上方 -->


<div class="header-inner" style="height: 100vh">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/blog/">
      <strong>Memory&#39;s blog</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/links/">
                <i class="iconfont icon-link-fill"></i>
                <span>友链</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/playlist/">
                <i class="iconfont icon-music"></i>
                <span>音乐</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/Memos/">
                <i class="iconfont icon-comment "></i>
                <span>说说</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/App/">
                <i class="iconfont icon-mobile"></i>
                <span>咫尺</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" target="_self" href="javascript:;" role="button"
                 data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <i class="iconfont icon-books"></i>
                <span>青简</span>
              </a>
              <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                
                  
                  
                  
                  <a class="dropdown-item" target="_blank" rel="noopener" href="http://47.93.135.62:5230/explore">
                    <i class="iconfont icon-images"></i>
                    <span>碎念微光</span>
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" href="/blog/New/">
                    <i class="iconfont icon-bug"></i>
                    <span>匠册详析</span>
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" href="/blog/New/">
                    <i class="iconfont icon-xbox-fill"></i>
                    <span>窗景新编</span>
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" href="/blog/New/">
                    <i class="iconfont icon-steam"></i>
                    <span>戏码幕后</span>
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" href="/blog/New/">
                    <i class="iconfont icon-map"></i>
                    <span>他山随拾</span>
                  </a>
                
              </div>
            </li>
          
        
        
            <li class="nav-item" id="search-btn">
                <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalNotice" aria-label="Search">
                    <i class="iconfont icon-book"></i>
                    <span>公告</span>
                </a>
            </li>
            
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>
 
<div id="banner" class="banner" parallax=true
     style="background: url('/blog/img/artical/grass20240808.jpg') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">

    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">

        <div class="h2">
          
            <span id="subtitle" data-typed-text="小程序开发经验分享：踩坑指南与技巧总结"></span>
          
        </div>


        
          <!-- 文章页面 - 顶部信息 -->

<div class="mt-3">
  
  <span class="post-meta mr-2">
    <i class="iconfont icon-author" aria-hidden="true"></i>
    Memory
  </span>
   
  <span class="post-meta">
    <i class="iconfont icon-date-fill" aria-hidden="true"></i>
    <time datetime="2023-07-30 18:42" pubdate>
      2023年7月30日 晚上
    </time>
  </span>
  
</div>

<div class="mt-1">
  
  <span class="post-meta mr-2">
    <i class="iconfont icon-chart"></i>
     29k 字 
  </span>
   
  <span class="post-meta mr-2">
    <i class="iconfont icon-clock-fill"></i>
       73 分钟 
  </span>
     
  <span
    id="leancloud-page-views-container"
    class="post-meta"
    style="display: none"
  >
    <i class="iconfont icon-eye" aria-hidden="true"></i>
    <span id="leancloud-page-views"></span> 次
  </span>

    
</div>


        

        <!-- 添加网站运行时间 -->
        <div class="footer-content" style="background-color: transparent;">
          <div>
            <span id="timeDate"></span>
            <span id="times"></span>
            <script>
            var now = new Date();
            function createtime(){
                var grt= new Date("03/07/2023 00:00:00");//此处修改你的建站时间或者网站上线时间
                now.setTime(now.getTime()+250);
                days = (now - grt ) / 1000 / 60 / 60 / 24;
                dnum = Math.floor(days);
                hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum);
                hnum = Math.floor(hours);
                if(String(hnum).length ==1 ){
                    hnum = "0" + hnum;
                }
                minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);
                mnum = Math.floor(minutes);
                if(String(mnum).length ==1 ){
                          mnum = "0" + mnum;
                }
                seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
                snum = Math.round(seconds);
                if(String(snum).length ==1 ){
                          snum = "0" + snum;
                }
                document.getElementById("timeDate").innerHTML = "🚀 &nbsp"+dnum+"&nbsp天";  //此次自定义显示内容
                document.getElementById("times").innerHTML = hnum + "&nbsp小时&nbsp" + mnum + "&nbsp分&nbsp" + snum + "&nbsp秒";
            }  

            if (!window.location.href.includes('/20')) {  
            setInterval("createtime()", 250);  // 只有当URL不包含'specific-page'时，才调用createtime  
            }//此次自定义显示内容
            </script>
          </div>
        </div>

      </div>
      
        <div class="scroll-down-bar">
          <i class="iconfont icon-arrowdown"></i>
        </div>
      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      <!-- 文章页  -->


<div class="container-fluid nopadding-x">

  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar category-bar" style="margin-right: -1rem">
    <!-- 文章页面 - 左边栏所属分类 -->
  

<!-- 文章页 - 文章分类 -->





<div class="category-list">
  
  
    
    
    
    <div class="category row nomargin-x">
      <a class="category-item 
          list-group-item category-item-action col-10 col-md-11 col-xm-11" title="代码锋芒"
        id="heading-843238cb7c4b39b52e95311733ff6da6" role="tab" data-toggle="collapse" href="#collapse-843238cb7c4b39b52e95311733ff6da6"
        aria-expanded="true"
      >
        代码锋芒
        <span class="list-group-count">(31)</span>
        <i class="iconfont icon-arrowright"></i>
      </a>
      
      <div class="category-collapse collapse show" id="collapse-843238cb7c4b39b52e95311733ff6da6"
           role="tabpanel" aria-labelledby="heading-843238cb7c4b39b52e95311733ff6da6">
        
        
          
          
  <div class="category-post-list">
    
    
      
      
        <a href="/blog/2023/03/19/MySQL%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/" title="MySQL安装配置"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">MySQL安装配置</span>
        </a>
      
    
      
      
        <a href="/blog/2023/03/22/MySQL%E4%BB%8E%E5%85%A5%E9%97%A8%E5%88%B0%E5%85%A5%E5%9C%9F/" title="MySQL从入门到入土"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">MySQL从入门到入土</span>
        </a>
      
    
      
      
        <a href="/blog/2023/04/09/Java%E6%B3%9B%E5%9E%8B%E7%9A%84%E7%90%86%E8%A7%A3/" title="Java泛型：赋予灵活性的利器"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">Java泛型：赋予灵活性的利器</span>
        </a>
      
    
      
      
        <a href="/blog/2023/05/21/%E6%8E%A2%E7%B4%A2%20Python%20%E7%88%AC%E8%99%AB%E7%9A%84%E6%97%A0%E9%99%90%E5%8F%AF%E8%83%BD%E6%80%A7%EF%BC%9A%E5%9F%BA%E7%A1%80%E4%B8%8E%E5%BA%94%E7%94%A8/" title="探索Python爬虫的无限可能性：基础与应用"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">探索Python爬虫的无限可能性：基础与应用</span>
        </a>
      
    
      
      
        <a href="/blog/2023/06/03/%E4%BB%8E%E9%9B%B6%E5%BC%80%E5%A7%8B%E7%9A%84%20JavaWeb%20%E4%B9%8B%E6%97%85/" title="从零开始的 JavaWeb 之旅"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">从零开始的 JavaWeb 之旅</span>
        </a>
      
    
      
      
        <a href="/blog/2023/06/10/%E6%95%B0%E6%8D%AE%E5%BA%93-%E5%AE%8C%E6%95%B4%E6%80%A7%E7%BA%A6%E6%9D%9F/" title="数据库-完整性约束"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">数据库-完整性约束</span>
        </a>
      
    
      
      
        <a href="/blog/2023/06/24/%E4%BD%BF%E7%94%A8%20JSP%20%E6%9E%84%E5%BB%BA%20JavaWeb%20%E9%A1%B9%E7%9B%AE-%E4%BB%A5%E6%95%B0%E6%8D%AE%E5%BA%93%E5%A4%A7%E4%BD%9C%E4%B8%9A%E4%B8%BA%E4%BE%8B/" title="使用JSP构建JavaWeb项目--以数据库大作业为例"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">使用JSP构建JavaWeb项目--以数据库大作业为例</span>
        </a>
      
    
      
      
        <a href="/blog/2023/07/06/%E6%89%93%E9%80%A0%E6%B5%81%E7%95%85%E7%BC%96%E7%A0%81%E4%B9%8B%E6%97%85%EF%BC%9AIntelliJ%20IDEA%20%E7%9A%84%E9%AB%98%E6%95%88%E4%BD%BF%E7%94%A8%E6%8A%80%E5%B7%A7%E4%B8%8E%E5%B7%A5%E4%BD%9C%E6%B5%81%E7%A8%8B%E4%BC%98%E5%8C%96/" title="打造流畅编码之旅：IntelliJ IDEA 的高效使用技巧与工作流程优化"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">打造流畅编码之旅：IntelliJ IDEA 的高效使用技巧与工作流程优化</span>
        </a>
      
    
      
      
        <a href="/blog/2023/07/06/%E5%87%A4%E5%87%B0%E6%B6%85%E6%A7%83%EF%BC%9ASpring%20Boot%20%E5%BC%80%E5%8F%91%E4%B9%8B%E8%B7%AF%E4%B8%8A%E7%9A%84%E5%9D%8E%E5%9D%B7%E4%B8%8E%E6%88%90%E9%95%BF/" title="凤凰涅槃：Spring Boot 开发之路上的坎坷与成长"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">凤凰涅槃：Spring Boot 开发之路上的坎坷与成长</span>
        </a>
      
    
      
      
        <a href="/blog/2023/07/11/%E4%BB%8EIP%E5%88%B0Ping%E5%91%BD%E4%BB%A4%EF%BC%9A%E4%BA%86%E8%A7%A3%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%E8%BF%9E%E6%8E%A5%E7%9A%84%E5%9F%BA%E7%A1%80/" title="从IP到Ping命令：了解计算机网络连接的基础"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">从IP到Ping命令：了解计算机网络连接的基础</span>
        </a>
      
    
      
      
        <a href="/blog/categories/%E4%BB%A3%E7%A0%81%E9%94%8B%E8%8A%92/" class="list-group-item list-group-item-action">
          <span class="category-post">More...</span>
        </a>
        
  </div>

          
  
    
    
    
    <div class="category-sub row nomargin-x">
      <a class="category-subitem collapsed
          list-group-item category-item-action col-10 col-md-11 col-xm-11" title="职路星火"
        id="heading-59c550454d1ecf67a2ead26a1c46d14b" role="tab" data-toggle="collapse" href="#collapse-59c550454d1ecf67a2ead26a1c46d14b"
        aria-expanded="false"
      >
        职路星火
        <span class="list-group-count">(2)</span>
        <i class="iconfont icon-arrowright"></i>
      </a>
      
      <div class="category-collapse collapse " id="collapse-59c550454d1ecf67a2ead26a1c46d14b"
           role="tabpanel" aria-labelledby="heading-59c550454d1ecf67a2ead26a1c46d14b">
        
        
          
  <div class="category-post-list">
    
    
      
      
        <a href="/blog/2024/03/07/%E7%A0%BA%E5%89%91%E5%87%BA%E9%9E%98%EF%BC%9A%E6%88%91%E7%9A%84%E8%BD%AF%E4%BB%B6%E5%B7%A5%E7%A8%8B%E5%B8%88%E6%B1%82%E8%81%8C%E4%B9%8B%E6%97%85/" title="砺剑出鞘：我的软件工程师求职之旅"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">砺剑出鞘：我的软件工程师求职之旅</span>
        </a>
      
    
      
      
        <a href="/blog/2024/04/16/%E6%8B%A8%E4%BA%91%E8%A7%81%E6%97%A5%EF%BC%9A%E8%81%8C%E5%9C%BA%E7%94%9F%E6%B4%BB%E7%9A%84%E7%82%B9%E6%BB%B4%E8%AE%B0%E5%BD%95/" title="拨云见日：职场生活的点滴记录"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">拨云见日：职场生活的点滴记录</span>
        </a>
      
    
  </div>

        
      </div>
    </div>
  
    
    
    
    <div class="category-sub row nomargin-x">
      <a class="category-subitem collapsed
          list-group-item category-item-action col-10 col-md-11 col-xm-11" title="部署之道"
        id="heading-36acf247b1a64f4bbe423776a392cfde" role="tab" data-toggle="collapse" href="#collapse-36acf247b1a64f4bbe423776a392cfde"
        aria-expanded="false"
      >
        部署之道
        <span class="list-group-count">(5)</span>
        <i class="iconfont icon-arrowright"></i>
      </a>
      
      <div class="category-collapse collapse " id="collapse-36acf247b1a64f4bbe423776a392cfde"
           role="tabpanel" aria-labelledby="heading-36acf247b1a64f4bbe423776a392cfde">
        
        
          
          
  <div class="category-post-list">
    
    
      
      
        <a href="/blog/2023/06/22/Nginx%20%E5%85%A5%E9%97%A8%E6%8C%87%E5%8D%97%EF%BC%9A%E7%90%86%E8%A7%A3%E3%80%81%E9%85%8D%E7%BD%AE%E5%92%8C%E4%BC%98%E5%8C%96/" title="Nginx 入门指南：理解、配置和优化"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">Nginx 入门指南：理解、配置和优化</span>
        </a>
      
    
      
      
        <a href="/blog/2023/07/11/Docker%20%E5%85%A5%E9%97%A8%E4%B8%8E%E5%AE%9E%E8%B7%B5%EF%BC%9A%E5%BF%AB%E9%80%9F%E6%89%93%E9%80%A0%E9%AB%98%E6%95%88%E7%BD%91%E7%AB%99%E9%83%A8%E7%BD%B2%E7%8E%AF%E5%A2%83/" title="Docker入门与实践：快速打造高效网站部署环境"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">Docker入门与实践：快速打造高效网站部署环境</span>
        </a>
      
    
      
      
        <a href="/blog/2023/08/17/%E6%B7%B1%E5%85%A5%E7%90%86%E8%A7%A3%20API%20%E7%BD%91%E5%85%B3%EF%BC%9A%E5%8E%9F%E7%90%86%E3%80%81%E5%8A%9F%E8%83%BD%E5%92%8C%E7%94%A8%E9%80%94/" title="深入理解 API 网关：原理、功能和用途"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">深入理解 API 网关：原理、功能和用途</span>
        </a>
      
    
  </div>

          
  
    
    
    
    <div class="category-sub row nomargin-x">
      <a class="category-subitem collapsed
          list-group-item category-item-action col-10 col-md-11 col-xm-11" title="职路星火"
        id="heading-59c550454d1ecf67a2ead26a1c46d14b" role="tab" data-toggle="collapse" href="#collapse-59c550454d1ecf67a2ead26a1c46d14b"
        aria-expanded="false"
      >
        职路星火
        <span class="list-group-count">(2)</span>
        <i class="iconfont icon-arrowright"></i>
      </a>
      
      <div class="category-collapse collapse " id="collapse-59c550454d1ecf67a2ead26a1c46d14b"
           role="tabpanel" aria-labelledby="heading-59c550454d1ecf67a2ead26a1c46d14b">
        
        
          
  <div class="category-post-list">
    
    
      
      
        <a href="/blog/2024/12/16/%E6%BC%AB%E6%BC%AB%E5%BE%81%E9%80%94%EF%BC%9A%E7%AD%91%E6%A2%A6%E4%BA%8E%E8%81%8C%E5%9C%BA%E9%A3%8E%E9%9B%A8%EF%BC%8C%E5%90%9F%E5%92%8F%E4%BA%8E%E6%97%A5%E5%B8%B8%E8%AF%97%E6%84%8F/" title="漫漫征途：筑梦于职场风雨，吟咏于日常诗意"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">漫漫征途：筑梦于职场风雨，吟咏于日常诗意</span>
        </a>
      
    
      
      
        <a href="/blog/2025/10/23/%E4%BF%9D%E9%A9%BE%E6%8A%A4%E8%88%AA%E2%80%94%E2%80%94%E5%90%8E%E5%8F%B0%E8%BF%90%E7%BB%B4%E8%A7%86%E8%A7%92%E4%B8%8B%E7%9A%84%E9%AB%98%E9%80%9F%E5%85%AC%E8%B7%AF%E2%80%9C%E7%94%9F%E5%91%BD%E7%BA%BF%E2%80%9D/" title="保驾护航——后台运维视角下的高速公路“生命线”"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">保驾护航——后台运维视角下的高速公路“生命线”</span>
        </a>
      
    
  </div>

        
      </div>
    </div>
  
        
      </div>
    </div>
  
    
    
    
    <div class="category-sub row nomargin-x">
      <a class="category-subitem 
          list-group-item category-item-action col-10 col-md-11 col-xm-11" title="项目志录"
        id="heading-005e56101bc2a873707cb4461a70ded8" role="tab" data-toggle="collapse" href="#collapse-005e56101bc2a873707cb4461a70ded8"
        aria-expanded="true"
      >
        项目志录
        <span class="list-group-count">(1)</span>
        <i class="iconfont icon-arrowright"></i>
      </a>
      
      <div class="category-collapse collapse show" id="collapse-005e56101bc2a873707cb4461a70ded8"
           role="tabpanel" aria-labelledby="heading-005e56101bc2a873707cb4461a70ded8">
        
        
          
  <div class="category-post-list">
    
    
      
      
        <a href="/blog/2023/07/30/%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%BC%80%E5%8F%91%E7%BB%8F%E9%AA%8C%E5%88%86%E4%BA%AB%EF%BC%9A%E8%B8%A9%E5%9D%91%E6%8C%87%E5%8D%97%E4%B8%8E%E6%8A%80%E5%B7%A7%E6%80%BB%E7%BB%93/" title="小程序开发经验分享：踩坑指南与技巧总结"
           class="list-group-item list-group-item-action
           active">
          <span class="category-post">小程序开发经验分享：踩坑指南与技巧总结</span>
        </a>
      
    
  </div>

        
      </div>
    </div>
  
        
      </div>
    </div>
  
</div>

  </aside>


    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">小程序开发经验分享：踩坑指南与技巧总结</h1>
            
              <p class="note note-success">
                
                  
                    本文最后更新于：5 个月前
                  
                
              </p>
            
            
              <div class="markdown-body">
                
                <h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>记录小程序开发过程中的问题。</p>
<h1 id="文章内容"><a href="#文章内容" class="headerlink" title="文章内容"></a>文章内容</h1><blockquote>
<p>2025 年 7 月 3 日</p>
</blockquote>
<p>点击跳转至文章页面。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">view</span></span><br><span class="hljs-tag">  <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;&#123;&#123;item.title&#125;&#125;&quot;</span></span><br><span class="hljs-tag">  <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;post-item&quot;</span></span><br><span class="hljs-tag">  <span class="hljs-attr">bindtap</span>=<span class="hljs-string">&quot;postClick&quot;</span></span><br><span class="hljs-tag">  <span class="hljs-attr">data-title</span>=<span class="hljs-string">&quot;&#123;&#123;item.title&#125;&#125;&quot;</span></span><br><span class="hljs-tag">  <span class="hljs-attr">data-path</span>=<span class="hljs-string">&quot;&#123;&#123;item.path&#125;&#125;&quot;</span></span><br><span class="hljs-tag">&gt;</span><br>  &#123;&#123;item.title&#125;&#125;<br><span class="hljs-tag">&lt;/<span class="hljs-name">view</span>&gt;</span><br></code></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-attr">postClick</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">option</span>) &#123;<br>  <span class="hljs-keyword">var</span> self = <span class="hljs-variable language_">this</span>;<br>  <span class="hljs-keyword">var</span> title =  option.<span class="hljs-property">target</span>.<span class="hljs-property">dataset</span>.<span class="hljs-property">title</span><br>  <span class="hljs-keyword">var</span> path = option.<span class="hljs-property">target</span>.<span class="hljs-property">dataset</span>.<span class="hljs-property">path</span><br>  wx.<span class="hljs-title function_">navigateTo</span>(&#123;<br>    <span class="hljs-attr">url</span>: <span class="hljs-string">&#x27;../artical/artical?path=&#x27;</span> + path,<br>  &#125;)<br>&#125;,<br></code></pre></td></tr></table></figure>

<p>在 article.js 中，编写如下函数。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-attr">onLoad</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">options</span>) &#123;<br>   <span class="hljs-keyword">var</span> self = <span class="hljs-variable language_">this</span>;<br>   <span class="hljs-keyword">var</span> markdownPath = options.<span class="hljs-property">path</span> || <span class="hljs-string">&#x27;../../pages/artical/test2.md&#x27;</span>; <span class="hljs-comment">// 默认路径（示例）</span><br><br>   <span class="hljs-comment">// 1. 读取本地 .md 文件</span><br>   wx.<span class="hljs-title function_">getFileSystemManager</span>().<span class="hljs-title function_">readFile</span>(&#123;<br>     <span class="hljs-attr">filePath</span>: markdownPath,<br>     <span class="hljs-attr">encoding</span>: <span class="hljs-string">&#x27;utf-8&#x27;</span>, <span class="hljs-comment">// 重要：确保以文本形式读取</span><br>     <span class="hljs-title function_">success</span>(<span class="hljs-params">res</span>) &#123;<br>       <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&#x27;Markdown内容:&#x27;</span>, res.<span class="hljs-property">data</span>);<br><br>       <span class="hljs-comment">// 2. 使用 towxml 解析 Markdown</span><br>       <span class="hljs-keyword">let</span> result = app.<span class="hljs-title function_">towxml</span>(res.<span class="hljs-property">data</span>, <span class="hljs-string">&#x27;markdown&#x27;</span>, &#123; <span class="hljs-comment">// 注意改为 markdown 类型</span><br>         <span class="hljs-attr">base</span>: <span class="hljs-string">&#x27;/pages/article/&#x27;</span>, <span class="hljs-comment">// 调整为基础路径</span><br>         <span class="hljs-attr">theme</span>: <span class="hljs-string">&#x27;light&#x27;</span>,<br>       &#125;);<br><br>       <span class="hljs-comment">// 3. 更新页面数据</span><br>       self.<span class="hljs-title function_">setData</span>(&#123;<br>         <span class="hljs-attr">article</span>: result,<br>         <span class="hljs-attr">showLoading</span>: <span class="hljs-literal">false</span>,<br>         <span class="hljs-attr">articaleTitle</span>: options.<span class="hljs-property">title</span> || <span class="hljs-string">&#x27;默认标题&#x27;</span>, <span class="hljs-comment">// 从参数或默认值获取标题</span><br>       &#125;);<br>     &#125;,<br>     <span class="hljs-title function_">fail</span>(<span class="hljs-params">err</span>) &#123;<br>       <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(<span class="hljs-string">&#x27;读取文件失败:&#x27;</span>, err);<br>       self.<span class="hljs-title function_">setData</span>(&#123; <span class="hljs-attr">showLoading</span>: <span class="hljs-literal">false</span> &#125;);<br>       wx.<span class="hljs-title function_">showToast</span>(&#123; <span class="hljs-attr">title</span>: <span class="hljs-string">&#x27;加载失败&#x27;</span>, <span class="hljs-attr">icon</span>: <span class="hljs-string">&#x27;none&#x27;</span> &#125;);<br>     &#125;<br>   &#125;);<br> &#125;,<br></code></pre></td></tr></table></figure>

<p>文章内容展示。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">view</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;container&quot;</span> <span class="hljs-attr">scroll-x</span>=<span class="hljs-string">&quot;true&quot;</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">towxml</span> <span class="hljs-attr">nodes</span>=<span class="hljs-string">&quot;&#123;&#123;article&#125;&#125;&quot;</span> /&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">view</span>&gt;</span><br></code></pre></td></tr></table></figure>

<p>这函数老是加载不到本地文件。</p>
<figure class="highlight arcade"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs arcade"><span class="hljs-built_in">console</span>.<span class="hljs-built_in">log</span>(<span class="hljs-string">&#x27;options:&#x27;</span>, options); <span class="hljs-comment">// 检查是否收到path参数</span><br><span class="hljs-keyword">var</span> markdownPath = options.path || <span class="hljs-string">&#x27;../../pages/article/test.md&#x27;</span>;<br><span class="hljs-built_in">console</span>.<span class="hljs-built_in">log</span>(<span class="hljs-string">&#x27;最终路径:&#x27;</span>, markdownPath); <span class="hljs-comment">// 确认路径拼接结果</span><br></code></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://segmentfault.com/q/1010000044342530">小程序 - wx.getFileSystemManager().readFile 读取文件没有权限，需要怎么处理？ - SegmentFault 思否</a></p>
<p>微信小程序中的<em>文件系统</em>其实类似浏览器中<a target="_blank" rel="noopener" href="https://link.segmentfault.com/?enc=YQQesKJ9gVdjIs6hyyGBiw==.BiHRJsskmZJDLW+0uJZN0HttZrqpykxtknHK31RGg1thyGVmD9bTn5LjCIai428K56F6DwarcPEijQMATQQIWlCaWTHCngOYEnrMay58648QJNjvXJNT0y1EWXn6s1Pe">Origin Private File System</a>的概念，它是供小程序使用的一块独立的文件区域，与代码文件和用户私有文件是独立的关系。你这里大概是想引用代码中的静态资源，是不能用这个 API 的。</p>
<blockquote>
<p>本地文件指的是小程序被用户添加到手机后，会有一块独立的文件存储区域，以用户维度隔离。即同一台手机，每个微信用户不能访问到其他登录用户的文件，同一个用户不同 appId 之间的文件也不能互相访问。</p>
</blockquote>
<p>艹。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">const</span> mdContent = <span class="hljs-built_in">require</span>(<span class="hljs-string">&quot;./test2.md.js&quot;</span>);<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(mdContent);<br><span class="hljs-comment">// 2. 使用 towxml 解析 Markdown</span><br><span class="hljs-keyword">let</span> result = app.<span class="hljs-title function_">towxml</span>(mdContent, <span class="hljs-string">&quot;markdown&quot;</span>, &#123;<br>  <span class="hljs-comment">// 注意改为 markdown 类型</span><br>  <span class="hljs-attr">base</span>: <span class="hljs-string">&quot;/pages/article/&quot;</span>, <span class="hljs-comment">// 调整为基础路径</span><br>  <span class="hljs-attr">theme</span>: <span class="hljs-string">&quot;light&quot;</span>,<br>&#125;);<br></code></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs bash">Error: Input data should be a String<br>    at i.parse (VM8153 markdown.js:370)<br>    at i.render (VM8153 markdown.js:374)<br>    at module.exports (VM8152 index.js:56)<br>    at Rt.module.exports (VM8113 index.js:11)<br>    at Rt.&lt;anonymous&gt; (WASubContext.js?t=wechat&amp;s=1751542853487&amp;v=3.8.9:1)<br>    at li.onLoad (artical.js? [sm]:38)<br>    at li.&lt;anonymous&gt; (WASubContext.js?t=wechat&amp;s=1751542853487&amp;v=3.8.9:1)<br>    at li.c.__callPageLifeTime__ (WASubContext.js?t=wechat&amp;s=1751542853487&amp;v=3.8.9:1)<br>    at WASubContext.js?t=wechat&amp;s=1751542853487&amp;v=3.8.9:1<br>    at WASubContext.js?t=wechat&amp;s=1751542853487&amp;v=3.8.9:1(<span class="hljs-built_in">env</span>: Windows,mp,1.06.2407110; lib: 3.8.9)<br></code></pre></td></tr></table></figure>

<p><code>towxml</code> 是一个专为微信小程序设计的 <strong>富文本/Markdown 解析库</strong>，它能将 HTML 或 Markdown 内容转换为小程序支持的 <code>WXML</code> 结构。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">let</span> result = app.<span class="hljs-title function_">towxml</span>(mdContent, <span class="hljs-string">&quot;markdown&quot;</span>, &#123;<br>  <span class="hljs-attr">base</span>: <span class="hljs-string">&quot;/pages/article/&quot;</span>,<br>  <span class="hljs-attr">theme</span>: <span class="hljs-string">&quot;light&quot;</span>,<br>&#125;);<br></code></pre></td></tr></table></figure>

<p>在 app.js 文件中：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">//app.js</span><br><span class="hljs-title class_">App</span>(&#123;<br>  <span class="hljs-attr">towxml</span>: <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;/towxml/index&#x27;</span>),<br><br>  .............................<br> )&#125;<br></code></pre></td></tr></table></figure>

<p>最终代码如下：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-attr">onLoad</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">options</span>) &#123;<br>   <span class="hljs-keyword">try</span> &#123;<br>     <span class="hljs-comment">// 读取本地文件</span><br>     <span class="hljs-keyword">const</span> mdModule = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;../../pages/artical/test2.md.js&#x27;</span>);<br>     <span class="hljs-comment">// 获取正文内容</span><br>     <span class="hljs-keyword">const</span> mdContent = <span class="hljs-keyword">typeof</span> mdModule === <span class="hljs-string">&#x27;string&#x27;</span> ? mdModule : mdModule.<span class="hljs-property">default</span> || <span class="hljs-string">&#x27;&#x27;</span>;<br>     <span class="hljs-keyword">if</span> (!mdContent) &#123;<br>       <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Error</span>(<span class="hljs-string">&#x27;Markdown内容为空&#x27;</span>);<br>     &#125;<br>     <span class="hljs-comment">// 使用 towxml 解析 Markdown</span><br>     <span class="hljs-keyword">let</span> result = app.<span class="hljs-title function_">towxml</span>(mdContent, <span class="hljs-string">&#x27;markdown&#x27;</span>, &#123;<br>       <span class="hljs-attr">base</span>: <span class="hljs-string">&#x27;/pages/article/&#x27;</span>,<br>       <span class="hljs-attr">theme</span>: <span class="hljs-string">&#x27;light&#x27;</span><br>     &#125;);<br>     <span class="hljs-comment">// 保存文章内容</span><br>     <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">setData</span>(&#123; <span class="hljs-attr">article</span>: result &#125;);<br>     <span class="hljs-comment">// 更新加载状态</span><br>     <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">setData</span>(&#123; <span class="hljs-attr">showLoading</span>: <span class="hljs-literal">false</span> &#125;);<br>   &#125; <span class="hljs-keyword">catch</span> (err) &#123;<br>     <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(<span class="hljs-string">&#x27;解析失败:&#x27;</span>, err);<br>     wx.<span class="hljs-title function_">showToast</span>(&#123; <span class="hljs-attr">title</span>: <span class="hljs-string">&#x27;内容加载失败&#x27;</span>, <span class="hljs-attr">icon</span>: <span class="hljs-string">&#x27;none&#x27;</span> &#125;);<br>   &#125;<br> &#125;,<br></code></pre></td></tr></table></figure>

<p>就这么直接把.md 转换成.js 文件不太妥当，只要文件里有代码块，整个文件就会报错，应为有符号冲突隔断的缘故。</p>
<h1 id="博客列表"><a href="#博客列表" class="headerlink" title="博客列表"></a>博客列表</h1><blockquote>
<p>2025 年 7 月 2 日</p>
</blockquote>
<p>构造模拟的博客文章列表数据。</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br></pre></td><td class="code"><pre><code class="hljs json"><span class="hljs-punctuation">[</span><br>  <span class="hljs-punctuation">&#123;</span><br>    <span class="hljs-attr">&quot;title&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Hexo 博客搭建指南&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;url&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024/01/01/hexo-blog-guide/&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;date&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024-01-01&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;excerpt&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;从零开始搭建 Hexo 静态博客的完整教程，包含主题配置和部署到 GitHub Pages。&quot;</span><br>  <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-punctuation">&#123;</span><br>    <span class="hljs-attr">&quot;title&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;JavaScript 设计模式实践&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;url&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024/01/05/javascript-design-patterns/&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;date&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024-01-05&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;excerpt&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;单例模式、观察者模式等常见 JavaScript 设计模式的代码示例和应用场景。&quot;</span><br>  <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-punctuation">&#123;</span><br>    <span class="hljs-attr">&quot;title&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;CSS Grid 布局完全指南&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;url&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024/01/10/css-grid-layout/&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;date&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024-01-10&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;excerpt&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;通过实战案例学习 CSS Grid 布局的核心概念和高级技巧。&quot;</span><br>  <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-punctuation">&#123;</span><br>    <span class="hljs-attr">&quot;title&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Node.js 性能优化策略&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;url&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024/01/15/nodejs-performance/&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;date&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024-01-15&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;excerpt&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;如何诊断和优化 Node.js 应用的 CPU、内存和 I/O 性能问题。&quot;</span><br>  <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-punctuation">&#123;</span><br>    <span class="hljs-attr">&quot;title&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;微信小程序开发踩坑记录&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;url&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024/01/20/wechat-miniprogram-tips/&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;date&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024-01-20&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;excerpt&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;分享开发微信小程序时遇到的 10 个常见问题及解决方案。&quot;</span><br>  <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-punctuation">&#123;</span><br>    <span class="hljs-attr">&quot;title&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Python 数据可视化实战&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;url&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024/01/25/python-data-visualization/&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;date&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024-01-25&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;excerpt&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;使用 Matplotlib 和 Seaborn 制作专业级数据图表的步骤详解。&quot;</span><br>  <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-punctuation">&#123;</span><br>    <span class="hljs-attr">&quot;title&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;React Hooks 最佳实践&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;url&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024/02/01/react-hooks-best-practices/&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;date&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024-02-01&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;excerpt&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;如何避免滥用 useEffect 并合理组织自定义 Hook 的逻辑。&quot;</span><br>  <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-punctuation">&#123;</span><br>    <span class="hljs-attr">&quot;title&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Git 高级用法备忘单&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;url&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024/02/05/git-advanced-tips/&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;date&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024-02-05&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;excerpt&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;rebase、cherry-pick 和 submodule 等 Git 高级功能的速查指南。&quot;</span><br>  <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-punctuation">&#123;</span><br>    <span class="hljs-attr">&quot;title&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;TypeScript 4.0 新特性解析&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;url&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024/02/10/typescript-4-features/&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;date&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024-02-10&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;excerpt&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;可变元组类型、标记元组元素等 TypeScript 4.0 重要更新详解。&quot;</span><br>  <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-punctuation">&#123;</span><br>    <span class="hljs-attr">&quot;title&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Docker 容器化部署实践&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;url&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024/02/15/docker-deployment/&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;date&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2024-02-15&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;excerpt&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;将 Node.js 应用容器化并通过 Docker Compose 管理多服务的完整流程。&quot;</span><br>  <span class="hljs-punctuation">&#125;</span><br><span class="hljs-punctuation">]</span><br></code></pre></td></tr></table></figure>

<hr>
<p><strong>数据字段说明</strong></p>
<table>
<thead>
<tr>
<th align="center">字段</th>
<th align="center">示例值</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>title</code></td>
<td align="center">“Hexo 博客搭建指南”</td>
<td align="center">文章标题</td>
</tr>
<tr>
<td align="center"><code>url</code></td>
<td align="center">“2024/01/01/hexo-blog-guide/“</td>
<td align="center">文章访问路径（需拼接域名）</td>
</tr>
<tr>
<td align="center"><code>date</code></td>
<td align="center">“2024-01-01”</td>
<td align="center">发布时间</td>
</tr>
<tr>
<td align="center"><code>excerpt</code></td>
<td align="center">“从零开始搭建…”</td>
<td align="center">文章摘要（可作简介）</td>
</tr>
</tbody></table>
<p>小程序请求数据。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// pages/index/index.js</span><br><span class="hljs-title class_">Page</span>(&#123;<br>  <span class="hljs-attr">data</span>: &#123;<br>    <span class="hljs-attr">articles</span>: [],<br>  &#125;,<br><br>  <span class="hljs-title function_">onLoad</span>(<span class="hljs-params"></span>) &#123;<br>    wx.<span class="hljs-title function_">request</span>(&#123;<br>      <span class="hljs-attr">url</span>: <span class="hljs-string">&quot;https://your-blog.com/articles.json&quot;</span>,<br>      <span class="hljs-attr">success</span>: <span class="hljs-function">(<span class="hljs-params">res</span>) =&gt;</span> &#123;<br>        <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">setData</span>(&#123; <span class="hljs-attr">articles</span>: res.<span class="hljs-property">data</span> &#125;);<br>      &#125;,<br>      <span class="hljs-attr">fail</span>: <span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> &#123;<br>        <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(<span class="hljs-string">&quot;加载失败&quot;</span>, err);<br>      &#125;,<br>    &#125;);<br>  &#125;,<br>&#125;);<br></code></pre></td></tr></table></figure>

<p>使用 require` 加载。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-attr">onLoad</span>: <span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) &#123;<br>   <span class="hljs-comment">// 直接 require 本地 JSON 文件</span><br>   <span class="hljs-keyword">const</span> articles = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;../../assets/data/articles.json&#x27;</span>);<br>   <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&quot;------------------------------&quot;</span>);<br>   <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(articles);<br>   <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(articles);<br>   <span class="hljs-comment">// this.setData(&#123; articles &#125;);</span><br> &#125;,<br></code></pre></td></tr></table></figure>

<figure class="highlight sas"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs sas">[基础库] 正在使用灰度中的基础库 3.8.10 进行调试。如有问题，请前往工具栏-详情-本地设置更改基础库版本。<br><span class="hljs-keyword">Error</span>: module <span class="hljs-string">&#x27;assets/data/articles.json.js&#x27;</span> is <span class="hljs-keyword">not</span> defined, require args is <span class="hljs-string">&#x27;../../assets/data/articles.json&#x27;</span><br>    at q (WASubContext.js?t=wechat<span class="hljs-variable">&amp;s</span>=1751451288428<span class="hljs-variable">&amp;v</span>=3.8.10:1)<br>    at n (WASubContext.js?t=wechat<span class="hljs-variable">&amp;s</span>=1751451288428<span class="hljs-variable">&amp;v</span>=3.8.10:1)<br>    at li.onLoad (<span class="hljs-keyword">index</span>.js? [sm]:15)<br>    at li.&lt;anonymous&gt; (WASubContext.js?t=wechat<span class="hljs-variable">&amp;s</span>=1751451288428<span class="hljs-variable">&amp;v</span>=3.8.10:1)<br>    at li.c.__callPageLifeTime__ (WASubContext.js?t=wechat<span class="hljs-variable">&amp;s</span>=1751451288428<span class="hljs-variable">&amp;v</span>=3.8.10:1)<br>    at WASubContext.js?t=wechat<span class="hljs-variable">&amp;s</span>=1751451288428<span class="hljs-variable">&amp;v</span>=3.8.10:1<br>    at WASubContext.js?t=wechat<span class="hljs-variable">&amp;s</span>=1751451288428<span class="hljs-variable">&amp;v</span>=3.8.10:1<br>    at WASubContext.js?t=wechat<span class="hljs-variable">&amp;s</span>=1751451288428<span class="hljs-variable">&amp;v</span>=3.8.10:1<br>    at WASubContext.js?t=wechat<span class="hljs-variable">&amp;s</span>=1751451288428<span class="hljs-variable">&amp;v</span>=3.8.10:1<br>    at WASubContext.js?t=wechat<span class="hljs-variable">&amp;s</span>=1751451288428<span class="hljs-variable">&amp;v</span>=3.8.10:1(env: Windows,mp,1.06.2407110; lib: 3.8.10)<br></code></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://jsonlint.com/">JSON Online Validator and Formatter - JSON Lint</a></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-attr">onLoad</span>:<span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) &#123;<br>  wx.<span class="hljs-title function_">request</span>(&#123;<br>    <span class="hljs-attr">url</span>: <span class="hljs-string">&#x27;../../assets/data/articles.json&#x27;</span>, <span class="hljs-comment">// 注意：需配置合法域名或开启不校验域名</span><br>    <span class="hljs-attr">success</span>: <span class="hljs-function">(<span class="hljs-params">res</span>) =&gt;</span> &#123;<br>      <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&#x27;原始数据:&#x27;</span>, res.<span class="hljs-property">data</span>);<br>      <span class="hljs-comment">// 确保数据是数组</span><br>      <span class="hljs-keyword">const</span> articles = <span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(res.<span class="hljs-property">data</span>) ? res.<span class="hljs-property">data</span> : [];<br>      <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">setData</span>(&#123; articles &#125;);<br>    &#125;,<br>    <span class="hljs-attr">fail</span>: <span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> &#123;<br>      <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(<span class="hljs-string">&#x27;加载失败&#x27;</span>, err);<br>    &#125;<br>  &#125;);<br>&#125;,<br></code></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">index.js? [sm]:23 加载失败 &#123;errno: 600009, errMsg: <span class="hljs-string">&quot;request:fail invalid url &quot;</span>../../assets/data/articles.json<span class="hljs-string">&quot;&quot;</span>&#125;errMsg: <span class="hljs-string">&quot;request:fail invalid url &quot;</span>../../assets/data/articles.json<span class="hljs-string">&quot;&quot;</span>errno: 600009__proto__: Object(<span class="hljs-built_in">env</span>: Windows,mp,1.06.2407110; lib: 3.8.10)<br></code></pre></td></tr></table></figure>

<p>这个错误是因为 <code>wx.request</code> <strong>不能直接使用本地相对路径</strong>加载文件，它只能请求网络 URL。有三种解决方案：</p>
<p><strong>改用 <code>require</code> 加载（推荐）</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-attr">onLoad</span>: <span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) &#123;<br>  <span class="hljs-keyword">try</span> &#123;<br>    <span class="hljs-comment">// 注意路径层级（可能需要调整 ../ 的数量）</span><br>    <span class="hljs-keyword">const</span> articles = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;../../assets/data/articles.json&#x27;</span>);<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&#x27;加载成功:&#x27;</span>, articles);<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">setData</span>(&#123; articles &#125;);<br>  &#125; <span class="hljs-keyword">catch</span> (err) &#123;<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(<span class="hljs-string">&#x27;加载失败:&#x27;</span>, err);<br>  &#125;<br>&#125;<br></code></pre></td></tr></table></figure>

<p><strong>使用 <code>wx.getFileSystemManager</code> 读取本地文件</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-attr">onLoad</span>: <span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) &#123;<br>  <span class="hljs-keyword">const</span> fs = wx.<span class="hljs-title function_">getFileSystemManager</span>();<br>  fs.<span class="hljs-title function_">readFile</span>(&#123;<br>    <span class="hljs-attr">filePath</span>: <span class="hljs-string">&#x27;assets/data/articles.json&#x27;</span>, <span class="hljs-comment">// 从项目根目录开始的路径</span><br>    <span class="hljs-attr">encoding</span>: <span class="hljs-string">&#x27;utf8&#x27;</span>,<br>    <span class="hljs-attr">success</span>: <span class="hljs-function">(<span class="hljs-params">res</span>) =&gt;</span> &#123;<br>      <span class="hljs-keyword">try</span> &#123;<br>        <span class="hljs-keyword">const</span> articles = <span class="hljs-title class_">JSON</span>.<span class="hljs-title function_">parse</span>(res.<span class="hljs-property">data</span>);<br>        <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">setData</span>(&#123; articles &#125;);<br>      &#125; <span class="hljs-keyword">catch</span> (e) &#123;<br>        <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(<span class="hljs-string">&#x27;JSON解析失败:&#x27;</span>, e);<br>      &#125;<br>    &#125;,<br>    <span class="hljs-attr">fail</span>: <span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> &#123;<br>      <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(<span class="hljs-string">&#x27;文件读取失败:&#x27;</span>, err);<br>    &#125;<br>  &#125;);<br>&#125;<br></code></pre></td></tr></table></figure>

<p>filePath 必须是从项目根目录开始的相对路径，例如：</p>
<ul>
<li>✅ <code>assets/data/articles.json</code></li>
<li>❌ <code>../../assets/data/articles.json</code></li>
</ul>
<p><strong>将 JSON 文件托管到网络</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs js">wx.<span class="hljs-title function_">request</span>(&#123;<br>  <span class="hljs-attr">url</span>: <span class="hljs-string">&quot;https://你的域名.com/articles.json&quot;</span>,<br>  <span class="hljs-attr">success</span>: <span class="hljs-function">(<span class="hljs-params">res</span>) =&gt;</span> &#123;<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">setData</span>(&#123; <span class="hljs-attr">articles</span>: res.<span class="hljs-property">data</span> &#125;);<br>  &#125;,<br>&#125;);<br></code></pre></td></tr></table></figure>

<p>需在小程序后台配置合法域名（设置 → 开发设置 → 服务器域名）</p>
<p>使用第二种方案，又出问题了：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash">[读取文件/文件夹警告] 无法读取 ../../assets/data/articles.json 文件或文件夹不在白名单中, 上传时会被忽略, 在真机上可能无法读取<br>index.js? [sm]:27 文件读取失败: &#123;errMsg: <span class="hljs-string">&quot;readFile:fail permission denied, open ../../assets/data/articles.json&quot;</span>&#125;errMsg: <span class="hljs-string">&quot;readFile:fail permission denied, open ../../assets/data/articles.json&quot;</span>__proto__: Object(<span class="hljs-built_in">env</span>: Windows,mp,1.06.2407110; lib: 3.8.10)<br></code></pre></td></tr></table></figure>

<p>他妈的，<code>filePath</code> 必须是从项目根目录开始的<strong>相对路径</strong>，不能使用 <code>../</code> 向上跳转，并且小程序默认只能读取特定目录下的文件（如 <code>assets</code> 需手动配置</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs js">wx.<span class="hljs-title function_">getFileSystemManager</span>().<span class="hljs-title function_">readFileSync</span>(<span class="hljs-string">&quot;assets/data/articles.json&quot;</span>, <span class="hljs-string">&quot;utf8&quot;</span>);<br></code></pre></td></tr></table></figure>

<p>成功了，终极解决方法，重命名文件为 <code>articles.js</code>，修改文件内容为：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// assets/data/articles.js</span><br><span class="hljs-variable language_">module</span>.<span class="hljs-property">exports</span> = [<br>  &#123;<br>    <span class="hljs-attr">title</span>: <span class="hljs-string">&quot;Hexo 博客搭建指南&quot;</span>,<br>    <span class="hljs-attr">url</span>: <span class="hljs-string">&quot;2024/01/01/hexo-blog-guide/&quot;</span>,<br>    <span class="hljs-attr">date</span>: <span class="hljs-string">&quot;2024-01-01&quot;</span>,<br>    <span class="hljs-attr">excerpt</span>: <span class="hljs-string">&quot;从零开始搭建Hexo...&quot;</span>,<br>  &#125;,<br>  <span class="hljs-comment">// 其他数据...</span><br>];<br></code></pre></td></tr></table></figure>

<p><strong>改用 <code>require</code> 加载：</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-attr">onLoad</span>: <span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) &#123;<br>  <span class="hljs-keyword">try</span> &#123;<br>    <span class="hljs-comment">// 注意路径层级（可能需要调整 ../ 的数量）</span><br>    <span class="hljs-keyword">const</span> articles = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;../../assets/data/articles.js&#x27;</span>);<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&#x27;加载成功:&#x27;</span>, articles);<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">setData</span>(&#123; articles &#125;);<br>  &#125; <span class="hljs-keyword">catch</span> (err) &#123;<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(<span class="hljs-string">&#x27;加载失败:&#x27;</span>, err);<br>  &#125;<br>&#125;,<br></code></pre></td></tr></table></figure>

<p><img src="http://blog.memory-life.xyz/image-20250702192104163.png" alt="image-20250702192104163"></p>
<p><img src="http://blog.memory-life.xyz/image-20250702192149421.png" alt="image-20250702192149421"></p>
<p>刚才发现，博客上传至七牛云对象存储的所有图片，也就是博客站点的所有图片，都备份保存在了本机 C 盘里。</p>
<figure class="highlight moonscript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs moonscript"><span class="hljs-name">C</span>:\Users\Lenovo\AppData\Roaming\Typora\typora-user-images<br></code></pre></td></tr></table></figure>

<p>足足两千四百六十九张图片。</p>
<p><a target="_blank" rel="noopener" href="https://developers.weixin.qq.com/miniprogram/dev/framework/ability/lazyload.html#%E7%94%A8%E6%97%B6%E6%B3%A8%E5%85%A5">按需注入和用时注入 | 微信开放文档 (qq.com)</a></p>
<p>一切准备就绪，上传第一个体验版本，仅供测试，代码质量校验提醒需要启动按需注入。</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs json"><span class="hljs-attr">&quot;lazyCodeLoading&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;requiredComponents&quot;</span><br></code></pre></td></tr></table></figure>

<p>搞定了，在 app.json 文件中添加如上代码即可实现按需注入。</p>
<p>上传完成。</p>
<h1 id="旧梦轻拾"><a href="#旧梦轻拾" class="headerlink" title="旧梦轻拾"></a>旧梦轻拾</h1><h2 id="初始化"><a href="#初始化" class="headerlink" title="初始化"></a>初始化</h2><blockquote>
<p>2025 年 5 月 16 日</p>
</blockquote>
<p><strong>个人主体</strong>：1 个邮箱只能绑定 1 个公众号或 1 个小程序。</p>
<p><img src="http://blog.memory-life.xyz/image-20250516171656234.png" alt="image-20250516171656234"></p>
<p><img src="http://blog.memory-life.xyz/image-20250516171616691.png" alt="image-20250516171616691"></p>
<p><strong>Jiomeng</strong>。</p>
<p><a target="_blank" rel="noopener" href="https://juejin.cn/post/7376180143376908300">从零开始三天学会微信小程序开发（一）看到不少入门的小程序开发者不断的问重复性的问题，我们从实战角度开发了这个课程，希望能 - 掘金 (juejin.cn)</a></p>
<p>选择模板，绑定小程序唯一 appID 创建小程序，编译并预览。</p>
<p>在创建小程序的对话框中，输入项目名称（如 StudentComment），选择项目存放的目录，AppID 一栏填写你在微信小程序官方后台中获取到的 AppID，后端服务选择“不使用云服务”，模板选择“JS-基础模板”，然后点击“确认”按钮，创建小程序。</p>
<p>可选择二维码预览，手机微信扫码即可体验；也可选择自动预览，选择启动手机端自动预览/启动 PC 端自动预览，相当方便。</p>
<p>待编译成功，会自动弹出小程序的最终运行效果，如下图所示。</p>
<p><img src="http://blog.memory-life.xyz/image-20250516173845596.png" alt="image-20250516173845596"></p>
<p>当我们开发好小程序之后，还需要把小程序上传到微信的服务器上。点击开发工具右上角的“上传”按钮，在弹出界面中输入更新类型、版本号和项目备注，然后点击上传，如下图所示。</p>
<p><img src="http://blog.memory-life.xyz/image-20250516173932305.png" alt="image-20250516173932305"></p>
<p>如果代码不存在任何问题，很快就会弹出“代码上传成功”的提示框，表示上传成功。</p>
<p>上传成功后，我们回到微信小程序官方后台。点击“版本管理” 链接，可以看到上传的小程序版本。如下图所示。</p>
<p><img src="http://blog.memory-life.xyz/image-20250516174139555.png" alt="image-20250516174139555"></p>
<p><strong>2022 年 6 月 8 日后，未设置主营类目的帐号将无法提交代码审核。</strong></p>
<p><img src="http://blog.memory-life.xyz/image-20250516174311152.png" alt="image-20250516174311152"></p>
<p>点击“提交审核”按钮，按要求填写资料。完成之后，会在审核版本中看到刚刚申请的审核版本，如下图所示。</p>
<p><img src="http://blog.memory-life.xyz/image-20250516174500309.png" alt="image-20250516174500309"></p>
<p>等到负责审核的工作人员通过之后，我们再执行最终的“发布”动作，我们开发的小程序才会出现在大众面前。</p>
<h2 id="新页面"><a href="#新页面" class="headerlink" title="新页面"></a>新页面</h2><blockquote>
<p>2025 年 5 月 16 日</p>
</blockquote>
<p>小程序标题，修改 app.json 文件。</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs json"><span class="hljs-punctuation">&#123;</span><br>  <span class="hljs-attr">&quot;pages&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">&quot;pages/detail/detail&quot;</span><span class="hljs-punctuation">,</span> <span class="hljs-string">&quot;pages/index/index&quot;</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-attr">&quot;window&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">&#123;</span><br>    <span class="hljs-attr">&quot;navigationBarTextStyle&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;black&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;navigationBarTitleText&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;社会脏话大全&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;navigationBarBackgroundColor&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;#ffffff&quot;</span><br>  <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-attr">&quot;style&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;v2&quot;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-attr">&quot;componentFramework&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;glass-easel&quot;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-attr">&quot;sitemapLocation&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;sitemap.json&quot;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-attr">&quot;lazyCodeLoading&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;requiredComponents&quot;</span><br><span class="hljs-punctuation">&#125;</span><br></code></pre></td></tr></table></figure>

<p>首页。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">view</span>&gt;</span>   减轻您的工作，一键生成各种评语 <span class="hljs-tag">&lt;/<span class="hljs-name">view</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">view</span>&gt;</span>   <span class="hljs-tag">&lt;<span class="hljs-name">navigator</span> <span class="hljs-attr">url</span>=<span class="hljs-string">&quot;/pages/detail/detail&quot;</span>&gt;</span>小学期末<span class="hljs-tag">&lt;/<span class="hljs-name">navigator</span>&gt;</span> <span class="hljs-tag">&lt;/<span class="hljs-name">view</span>&gt;</span><br></code></pre></td></tr></table></figure>

<p>奶奶的，多打了一个斜杠，老是报错，问 AI 也说不清道不明的。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs html">  <span class="hljs-tag">&lt;<span class="hljs-name">navigator</span> <span class="hljs-attr">url</span>=<span class="hljs-string">&quot;pages/index/index&quot;</span>&gt;</span> 小学期末 <span class="hljs-tag">&lt;/<span class="hljs-name">navigator</span>&gt;</span><br></code></pre></td></tr></table></figure>

<p>什么垃圾编译器。。。</p>
<blockquote>
<p>2025 年 5 月 17 日</p>
</blockquote>
<p>见鬼了，看来是直接粘贴代码携带隐藏符号了，亲手敲代码不会有报错。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-comment">&lt;!--index.wxml--&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">view</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;head&quot;</span>&gt;</span>   减轻您的工作，一键生成各种评语 <span class="hljs-tag">&lt;/<span class="hljs-name">view</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">view</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;links&quot;</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">navigator</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;btn&quot;</span> <span class="hljs-attr">url</span>=<span class="hljs-string">&quot;/pages/detail/detail&quot;</span>&gt;</span> 脏话集锦 <span class="hljs-tag">&lt;/<span class="hljs-name">navigator</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">view</span>&gt;</span><br></code></pre></td></tr></table></figure>

<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-selector-class">.head</span> &#123;<br>  <span class="hljs-attribute">display</span>: flex;<br>  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">36</span>rpx;<br>  <span class="hljs-attribute">justify-content</span>: center;<br>  <span class="hljs-attribute">margin-top</span>: <span class="hljs-number">40</span>rpx;<br>&#125;<br><br><span class="hljs-selector-class">.links</span> &#123;<br>  <span class="hljs-attribute">display</span>: flex;<br>  <span class="hljs-attribute">justify-content</span>: center;<br>  <span class="hljs-attribute">margin-top</span>: <span class="hljs-number">30</span>rpx;<br>&#125;<br><br><span class="hljs-selector-class">.btn</span> &#123;<br>  <span class="hljs-attribute">border</span>: <span class="hljs-number">2px</span> solid <span class="hljs-number">#5db59d</span>;<br>  <span class="hljs-attribute">padding</span>: <span class="hljs-number">20</span>rpx;<br>  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">20</span>rpx;<br>  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">28</span>rpx;<br>&#125;<br></code></pre></td></tr></table></figure>

<p>绑定数据。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 页面的初始数据</span><br><span class="hljs-comment"> */</span><br><span class="hljs-attr">data</span>: &#123;<br>  <span class="hljs-attr">info</span>: <span class="hljs-string">&quot;减轻您的工作，一键生成各种评语&quot;</span>,<br>  <span class="hljs-attr">links</span>: [<span class="hljs-string">&#x27;轻度调侃&#x27;</span>, <span class="hljs-string">&#x27;激烈宣泄&#x27;</span>, <span class="hljs-string">&#x27;讽刺反讽&#x27;</span>]<br>&#125;,<br></code></pre></td></tr></table></figure>

<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">view</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;links&quot;</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">navigator</span></span><br><span class="hljs-tag">    <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;btn&quot;</span></span><br><span class="hljs-tag">    <span class="hljs-attr">url</span>=<span class="hljs-string">&quot;/pages/detail/detail&quot;</span></span><br><span class="hljs-tag">    <span class="hljs-attr">wx:for</span>=<span class="hljs-string">&quot;&#123;&#123;links&#125;&#125;&quot;</span></span><br><span class="hljs-tag">    <span class="hljs-attr">wx:for-item</span>=<span class="hljs-string">&quot;link&quot;</span></span><br><span class="hljs-tag">  &gt;</span><br>    &#123;&#123;link&#125;&#125;<br>  <span class="hljs-tag">&lt;/<span class="hljs-name">navigator</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">view</span>&gt;</span><br></code></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://juejin.cn/post/7376556275973374015">从零开始三天学会微信小程序开发（二）看到不少入门的小程序开发者不断的问重复性的问题，我们从实战角度开发了这个课程，希望能 - 掘金 (juejin.cn)</a></p>
<p><img src="http://blog.memory-life.xyz/image-20250517152605068.png" alt="image-20250517152605068"></p>
<p><a target="_blank" rel="noopener" href="https://gitee.com/bmober/hydrogen-js-sdk/blob/master/dist/Bmob-2.5.30.min.js">dist/Bmob-2.5.30.min.js · 元素（深圳）软件有限公司/hydrogen-js-sdk - Gitee.com</a></p>
<p><img src="http://blog.memory-life.xyz/image-20250517155606506.png" alt="image-20250517155606506"></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">const</span> <span class="hljs-title class_">Bmob</span> = <span class="hljs-built_in">require</span>(<span class="hljs-string">&quot;/utils/Bmob-2.5.30.min.js&quot;</span>);<br><span class="hljs-title class_">Bmob</span>.<span class="hljs-title function_">initialize</span>(<span class="hljs-string">&quot;你的Secret Key&quot;</span>, <span class="hljs-string">&quot;你的API 安全码&quot;</span>);<br>wx.<span class="hljs-property">Bmob</span> = <span class="hljs-title class_">Bmob</span>;<br></code></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://mp.weixin.qq.com/cgi-bin/loginpage?url=/cgi-bin/home?t=home/index&lang=zh_CN&token=2101502474">微信公众平台 (qq.com)</a></p>
<p><a target="_blank" rel="noopener" href="https://www.bmobapp.com/app/secret/334123">应用密钥 - Bmob 后端云 (bmobapp.com)</a></p>
<p><img src="http://blog.memory-life.xyz/image-20250517161022104.png" alt="image-20250517161022104"></p>
<h2 id="审核"><a href="#审核" class="headerlink" title="审核"></a>审核</h2><blockquote>
<p>2025 年 5 月 19 日</p>
</blockquote>
<p>上周提交的小程序竟审核未通过。</p>
<p><img src="http://blog.memory-life.xyz/image-20250519183959125.png" alt="image-20250519183959125"></p>
<p>测试代码不能提交。</p>
<p>应该写个开发日志。</p>
<p>库表设计：图片信息（图片名，图片链接，图片尺寸，图片分辨率，图片大小，标签）。</p>
<p>先写后端，核心接口：图片列表展示，图片详情信息，上传图片，下载图片。</p>
<p>再写前端，核心页面：图片列表，图片详情信息。</p>
<h2 id="业务域名"><a href="#业务域名" class="headerlink" title="业务域名"></a>业务域名</h2><blockquote>
<p>2025 年 6 月 27 日</p>
</blockquote>
<p><a target="_blank" rel="noopener" href="https://developers.weixin.qq.com/doc/oplatform/Website_App/guideline/domain.html">操作指南 / 业务域名配置 (qq.com)</a></p>
<p><a target="_blank" rel="noopener" href="https://baijiahao.baidu.com/s?id=1834749108125837203&wfr=spider&for=pc">微信小程序快速入门：从开发者工具到业务域名配置 (baidu.com)</a></p>
<p><a target="_blank" rel="noopener" href="https://developers.weixin.qq.com/doc/oplatform/Website_App/guideline/domain.html">操作指南 / 业务域名配置 (qq.com)</a></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-comment">&lt;!--index.wxml--&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">scroll-view</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;scrollarea&quot;</span> <span class="hljs-attr">scroll-y</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;list&quot;</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">view</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;container&quot;</span>&gt;</span><br>    <span class="hljs-comment">&lt;!-- page.wxml --&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">web-view</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;https://deng-2022.atomgit.net/blog/&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">web-view</span>&gt;</span><br>  <span class="hljs-tag">&lt;/<span class="hljs-name">view</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">scroll-view</span>&gt;</span><br></code></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://developers.weixin.qq.com/miniprogram/dev/framework/">微信开放文档 / 开发 (qq.com)</a></p>
<p><a target="_blank" rel="noopener" href="https://diy.seowhy.com/help/10.html">个人类型的小程序支持业务域名吗？ (seowhy.com)</a></p>
<p><a target="_blank" rel="noopener" href="http://www.apppark.cn/t-54179.html">个人小程序支持业务域名吗? (apppark.cn)</a></p>
<blockquote>
<p>2025 年 6 月 28 日</p>
</blockquote>
<p><a target="_blank" rel="noopener" href="https://developers.weixin.qq.com/miniprogram/dev/framework/ability/domain.html">基础能力 / 网络 / 业务域名 (qq.com)</a></p>
<ol>
<li>在管理后台配置业务域名</li>
</ol>
<p>开发者登录小程序后台 mp.weixin.qq.com，选择开发管理-&gt;开发设置-&gt;业务域名，点击新增，按照要求配置业务域名。目前小程序内嵌网页能力暂不开放给个人类型账号和小游戏账号。</p>
<p><img src="http://blog.memory-life.xyz/domain.dbb33f74.png" alt="img"></p>
<ol start="2">
<li>调用 web-view 组件实现小程序内嵌网页</li>
</ol>
<p>在小程序管理后台成功配置业务域名后，才可使用 web-view 组件。小程序内调用 web-view 组件实现内嵌的网页，目前仅支持部分 jsapi 能力，关于 web-view 接口具体使用说明和限制，请 <a target="_blank" rel="noopener" href="https://developers.weixin.qq.com/miniprogram/dev/component/web-view.html">点击查看</a></p>
<h1 id="界面设计"><a href="#界面设计" class="headerlink" title="界面设计"></a>界面设计</h1><blockquote>
<p>2025 年 7 月 1 日</p>
</blockquote>
<p><a target="_blank" rel="noopener" href="https://juejin.cn/post/7304866019621011492?searchId=2025070112032992D0041FB1D00A968F97">小程序界面设计模板分享，前端开发进来看身处于网络世界日新月异的变革中，智能手机已然成为我们日常生活、学习和工作的必不可少 - 掘金 (juejin.cn)</a></p>
<p><a target="_blank" rel="noopener" href="https://developers.weixin.qq.com/community/develop/doc/000ca29f3a0e00e380923c3c366c00">微信开放社区 (qq.com)-订阅号的 appid 在哪里看？</a></p>
<p><a target="_blank" rel="noopener" href="https://console.cloud.tencent.com/cos/bucket?type=object&tab=objectDetail&bucket=memory-1318574676&path=/redirect.html&region=ap-nanjing">存储桶列表 - 对象存储 - 控制台 (tencent.com)</a></p>
<p>微信现在对<strong>个人订阅号</strong>的菜单跳转实行 <strong>「白名单+内容归属校验」</strong>：</p>
<ol>
<li>仅允许跳转至：<ul>
<li>公众号后台的图文消息页面（<code>mp.weixin.qq.com/...</code>）</li>
<li>已关联的<strong>小程序</strong>（需开发者权限）</li>
<li>腾讯系域名（如 QQ 音乐、腾讯视频等）</li>
</ul>
</li>
<li>完全禁止：<ul>
<li>任何外部链接（即使备案、即使使用腾讯云 COS 中转）</li>
<li>GitHub Pages、自建博客、第三方平台链接</li>
</ul>
</li>
</ol>
<p><a target="_blank" rel="noopener" href="https://cloud.tencent.com/document/product/213/495">云服务器</a>（ Cloud Virtual Machine，CVM ）为您提供安全可靠的弹性计算服务。</p>
<p>阿里云 ECS 是阿里云提供的弹性计算服务（Elastic Compute Service），一种可弹性伸缩的虚拟服务器。</p>
<p>微信公众平台跳转至外部链接，限制太死板了，简直不像是 5G 时代应该有的产物，毫无自由度。</p>
<h1 id="PicMemories"><a href="#PicMemories" class="headerlink" title="PicMemories"></a>PicMemories</h1><blockquote>
<p>2025 年 1 月 11 日</p>
</blockquote>
<p>后端刚启动就报错，这么刺激：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs bash">Connected to the target VM, address: <span class="hljs-string">&#x27;127.0.0.1:10270&#x27;</span>, transport: <span class="hljs-string">&#x27;socket&#x27;</span><br>16:26:56.138 [main] DEBUG reactor.util.Loggers - Using Slf4j logging framework<br>16:26:56.142 [main] DEBUG reactor.core.publisher.Hooks - Enabling stacktrace debugging via onOperatorDebug<br>16:26:57.051 [main] ERROR org.springframework.boot.SpringApplication - Application run failed<br>org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1<br>	at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:218)<br></code></pre></td></tr></table></figure>

<p>竟然又是配置文件带了中文，这么古老。</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">knife4j:</span><br>  <span class="hljs-attr">enable:</span> <span class="hljs-literal">true</span><br>  <span class="hljs-attr">openapi:</span><br>    <span class="hljs-attr">title:</span> <span class="hljs-string">PicMemories</span> <span class="hljs-string">接口文档</span><br>    <span class="hljs-attr">description:</span> <span class="hljs-string">PicMemories</span> <span class="hljs-string">壁纸分享小程序</span><br>    <span class="hljs-attr">concat:</span> <span class="hljs-number">3348407547</span><span class="hljs-string">@qq.com</span><br>    <span class="hljs-attr">url:</span> <span class="hljs-string">https://deng-2022.gitee.io/blog/</span><br>    <span class="hljs-attr">version:</span> <span class="hljs-number">1.0</span><br>    <span class="hljs-attr">license:</span> <span class="hljs-string">Apache</span> <span class="hljs-number">2.0</span><br>    <span class="hljs-attr">group:</span><br>      <span class="hljs-attr">test1:</span><br>        <span class="hljs-attr">group-name:</span> <span class="hljs-string">壁纸分享</span><br></code></pre></td></tr></table></figure>

<p>启动成功。</p>
<p><img src="http://blog.memory-life.xyz/image-20250111164802113.png" alt="image-20250111164802113"></p>
<p>启动第一步，先把图床资源翻新下，前年用七牛云的临时域名，图片链接早都过期了。</p>
<p>这个小程序初步计划仅实现最核心的功能，即服务端上传图片，小程序端下载图片。</p>
<p>想起来当时是因为暑假那会儿有同学找我组队，说是需要一个会做小程序的，我从零开始边学边做，两周左右的时间就完善了基本页面。</p>
<p>后来这个同学就没有消息了，小程序也暂且搁置。</p>
<p>当时把页面分为四个板块：精选，分类，频道，我的，其实是想实现一个集交友，壁纸下载，聊天等的小程序。</p>
<p>不过没什么使用价值，连壁纸究竟该提供哪些分类和数量都没有想法，大部分编码时间里都在纠结图片间距和预览效果，其核心功能开发倒没多少进展。</p>
<p>直到昨天。</p>
<p>昨天下午我想起来那会儿确实也想要做一个个人网站，尝试学习不同领域的知识，小程序，Web，桌面端，保持学习的心态去实现心愿。</p>
<p>后来确实做到了，我成功运营起来自己的个人博客网站，相当成功。</p>
<p>昨天又想起来自己之前一直想搭建文档站点，后来还尝试开发过壁纸分享小程序，这两项工作也是时候该完成了。</p>
<p>文档站点，可以选择提炼出个人博客网站中的编程学习经验栏目；而壁纸分享小程序，则专门用来收录个人博客站点的精选壁纸图片。</p>
<p>初步打造属于自己的全生态软件集合。</p>
<p>时间还有很多，先执行起来吧。</p>
<h1 id="小程序开发"><a href="#小程序开发" class="headerlink" title="小程序开发"></a>小程序开发</h1><blockquote>
<p>2023 年 7 月 30 日</p>
</blockquote>
<h2 id="开发准备"><a href="#开发准备" class="headerlink" title="开发准备"></a>开发准备</h2><p>HBuilderX+uni-app+uinCloud</p>
<ul>
<li><h5 id="uni-app-官网-dcloud-net-cn"><a href="#uni-app-官网-dcloud-net-cn" class="headerlink" title="uni-app 官网 (dcloud.net.cn)"></a><a target="_blank" rel="noopener" href="https://uniapp.dcloud.net.cn/">uni-app 官网 (dcloud.net.cn)</a></h5></li>
<li><h5 id="87-条消息-为-uni-cloud（Dcloud-国产之辉）声明！lqj本人的博客-CSDN-博客"><a href="#87-条消息-为-uni-cloud（Dcloud-国产之辉）声明！lqj本人的博客-CSDN-博客" class="headerlink" title="(87 条消息) 为 uni-cloud（Dcloud 国产之辉）声明！lqj本人的博客-CSDN 博客"></a><a target="_blank" rel="noopener" href="https://blog.csdn.net/lbcyllqj/article/details/131135791">(87 条消息) 为 uni-cloud（Dcloud 国产之辉）声明！<em>lqj</em>本人的博客-CSDN 博客</a></h5></li>
</ul>
<p>微信开发者工具连接失败</p>
<p><img src="http://blog.memory-life.xyz/image-20230803210244455.png" alt="image-20230803210244455"></p>
<p><img src="http://blog.memory-life.xyz/image-20230803210305939.png" alt="image-20230803210305939"></p>
<p><img src="http://blog.memory-life.xyz/image-20230803210317551.png" alt="image-20230803210317551"></p>
<h1 id="微信开发者工具"><a href="#微信开发者工具" class="headerlink" title="微信开发者工具"></a>微信开发者工具</h1><ul>
<li><h5 id="最近在开发-PicMemories-壁纸分享小程序，浅浅记录遇到的一些问题"><a href="#最近在开发-PicMemories-壁纸分享小程序，浅浅记录遇到的一些问题" class="headerlink" title="最近在开发 PicMemories 壁纸分享小程序，浅浅记录遇到的一些问题"></a>最近在开发 PicMemories 壁纸分享小程序，浅浅记录遇到的一些问题</h5></li>
</ul>
<h2 id="请求域名不合法"><a href="#请求域名不合法" class="headerlink" title="请求域名不合法"></a>请求域名不合法</h2><ul>
<li><h5 id="开发过程中，不校验合法域名："><a href="#开发过程中，不校验合法域名：" class="headerlink" title="开发过程中，不校验合法域名："></a>开发过程中，不校验合法域名：</h5></li>
</ul>
<p><img src="http://blog.memory-life.xyz/image-20230803192902265.png" alt="image-20230803192902265"></p>
<p><img src="http://blog.memory-life.xyz/image-20230803192858399.png" alt="image-20230803192858399"></p>
<ul>
<li><h5 id="小程序·不在以下-request-合法域名列表中及域名配置-菜鸟婷婷-博客园-cnblogs-com"><a href="#小程序·不在以下-request-合法域名列表中及域名配置-菜鸟婷婷-博客园-cnblogs-com" class="headerlink" title="小程序·不在以下 request 合法域名列表中及域名配置 - 菜鸟婷婷 - 博客园 (cnblogs.com)"></a><a target="_blank" rel="noopener" href="https://www.cnblogs.com/cntt/p/12988539.html">小程序·不在以下 request 合法域名列表中及域名配置 - 菜鸟婷婷 - 博客园 (cnblogs.com)</a></h5></li>
<li><h5 id="小程序合法域名配置："><a href="#小程序合法域名配置：" class="headerlink" title="小程序合法域名配置："></a>小程序合法域名配置：</h5></li>
</ul>
<p><img src="http://blog.memory-life.xyz/image-20230803210743470.png" alt="image-20230803210743470"></p>
<h2 id="全局封装-request"><a href="#全局封装-request" class="headerlink" title="全局封装 request"></a>全局封装 request</h2><ul>
<li>安装 axios：</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">npm install axios<br></code></pre></td></tr></table></figure>

<ul>
<li>app.js 下做如下配置：</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-title class_">App</span>(&#123;<br>  <span class="hljs-title function_">request</span>(<span class="hljs-params">options</span>) &#123;<br>    <span class="hljs-keyword">const</span> &#123; url, method, data, success, fail &#125; = options;<br>    wx.<span class="hljs-title function_">request</span>(&#123;<br>      url,<br>      method,<br>      data,<br>      <span class="hljs-title function_">success</span>(<span class="hljs-params">res</span>) &#123;<br>        success &amp;&amp; <span class="hljs-title function_">success</span>(res.<span class="hljs-property">data</span>);<br>      &#125;,<br>      <span class="hljs-title function_">fail</span>(<span class="hljs-params">error</span>) &#123;<br>        fail &amp;&amp; <span class="hljs-title function_">fail</span>(error);<br>      &#125;,<br>    &#125;);<br>  &#125;,<br>  <span class="hljs-attr">onLaunch</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-comment">// 小程序启动时触发，可以进行一些初始化操作</span><br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&quot;App launched&quot;</span>);<br>  &#125;,<br>  <span class="hljs-attr">onShow</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-comment">// 小程序进入前台时触发</span><br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&quot;App showed&quot;</span>);<br>  &#125;,<br>  <span class="hljs-attr">onHide</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-comment">// 小程序进入后台时触发</span><br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&quot;App hided&quot;</span>);<br>  &#125;,<br>  <span class="hljs-attr">globalData</span>: &#123;<br>    <span class="hljs-attr">userInfo</span>: <span class="hljs-literal">null</span>, <span class="hljs-comment">// 全局用户信息</span><br>    <span class="hljs-attr">themeColor</span>: <span class="hljs-string">&quot;#F44336&quot;</span>, <span class="hljs-comment">// 全局主题颜色</span><br>  &#125;,<br>&#125;);<br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="index-js-下如此请求："><a href="#index-js-下如此请求：" class="headerlink" title="index.js 下如此请求："></a>index.js 下如此请求：</h5></li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">const</span> app = <span class="hljs-title function_">getApp</span>();<br></code></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs js">app.<span class="hljs-title function_">request</span>(&#123;<br>  <span class="hljs-attr">url</span>: <span class="hljs-string">&quot;http://localhost:8084/api/user/current&quot;</span>,<br>  <span class="hljs-attr">method</span>: <span class="hljs-string">&quot;GET&quot;</span>,<br>  <span class="hljs-attr">success</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">data</span>) &#123;<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(data);<br>  &#125;,<br>  <span class="hljs-attr">fail</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">error</span>) &#123;<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(error);<br>  &#125;,<br>&#125;);<br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="我这里后端接收请求出现如下错误："><a href="#我这里后端接收请求出现如下错误：" class="headerlink" title="我这里后端接收请求出现如下错误："></a>我这里后端接收请求出现如下错误：</h5></li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">Invalid character found <span class="hljs-keyword">in</span> method name [0x160x030x010x020x000x010x000x010xfc0x030x031E0xe3]0x8eQ0xd60x0e0xf7mJ0x950x920x810xe00x0c0x820xb5)0xc70xdf0xefY0xe30xb8|0x9d0xd430xe50x8f5 ]. HTTP method names must be tokens<br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="经排查，是因为把-http-写成-https-了："><a href="#经排查，是因为把-http-写成-https-了：" class="headerlink" title="经排查，是因为把 http 写成 https 了："></a>经排查，是因为把 http 写成 https 了：</h5></li>
</ul>
<p><img src="http://blog.memory-life.xyz/image-20230803194528518.png" alt="image-20230803194528518"></p>
<p><img src="http://blog.memory-life.xyz/image-20230803194648359.png" alt="image-20230803194648359"></p>
<p><img src="http://blog.memory-life.xyz/image-20230803194709864.png" alt="image-20230803194709864"></p>
<h2 id="数据双向绑定"><a href="#数据双向绑定" class="headerlink" title="数据双向绑定"></a>数据双向绑定</h2><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">van-cell-group</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">van-field</span></span><br><span class="hljs-tag">    <span class="hljs-attr">required</span></span><br><span class="hljs-tag">    <span class="hljs-attr">model:value</span>=<span class="hljs-string">&quot;&#123;&#123;username&#125;&#125;&quot;</span></span><br><span class="hljs-tag">    <span class="hljs-attr">label</span>=<span class="hljs-string">&quot;昵称&quot;</span></span><br><span class="hljs-tag">    <span class="hljs-attr">placeholder</span>=<span class="hljs-string">&quot;请输入昵称&quot;</span></span><br><span class="hljs-tag">  /&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">van-field</span></span><br><span class="hljs-tag">    <span class="hljs-attr">required</span></span><br><span class="hljs-tag">    <span class="hljs-attr">model:value</span>=<span class="hljs-string">&quot;&#123;&#123;phone&#125;&#125;&quot;</span></span><br><span class="hljs-tag">    <span class="hljs-attr">label</span>=<span class="hljs-string">&quot;密码&quot;</span></span><br><span class="hljs-tag">    <span class="hljs-attr">placeholder</span>=<span class="hljs-string">&quot;请设置密码&quot;</span></span><br><span class="hljs-tag">  /&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">van-field</span></span><br><span class="hljs-tag">    <span class="hljs-attr">required</span></span><br><span class="hljs-tag">    <span class="hljs-attr">model:value</span>=<span class="hljs-string">&quot;&#123;&#123;password&#125;&#125;&quot;</span></span><br><span class="hljs-tag">    <span class="hljs-attr">label</span>=<span class="hljs-string">&quot;手机号&quot;</span></span><br><span class="hljs-tag">    <span class="hljs-attr">placeholder</span>=<span class="hljs-string">&quot;请输入手机号&quot;</span></span><br><span class="hljs-tag">  /&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">van-cell-group</span>&gt;</span><br></code></pre></td></tr></table></figure>

<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-attr">data</span>: &#123;<br>  <span class="hljs-attr">username</span>: <span class="hljs-string">&#x27;&#x27;</span>,<br>  <span class="hljs-attr">password</span>: <span class="hljs-string">&#x27;&#x27;</span>,<br>  <span class="hljs-attr">phone</span>: <span class="hljs-string">&#x27;&#x27;</span><br>&#125;,<br></code></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-title function_">goToRegister</span>(<span class="hljs-params"></span>) &#123;<br>    app.<span class="hljs-title function_">request</span>(&#123;<br>      <span class="hljs-attr">url</span>: <span class="hljs-string">&#x27;http://localhost:8084/api/user/register&#x27;</span>,<br>      <span class="hljs-attr">method</span>: <span class="hljs-string">&#x27;POST&#x27;</span>,<br>      <span class="hljs-attr">data</span>: &#123;<br>        <span class="hljs-attr">username</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">data</span>.<span class="hljs-property">username</span>,<br>        <span class="hljs-attr">password</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">data</span>.<span class="hljs-property">password</span>,<br>        <span class="hljs-attr">phone</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">data</span>.<span class="hljs-property">phone</span><br>      &#125;,<br>      <span class="hljs-attr">success</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">data</span>) &#123;<br>        <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(data);<br>      &#125;,<br>      <span class="hljs-attr">fail</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">error</span>) &#123;<br>        <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(error);<br>      &#125;<br>    &#125;)<br>  &#125;,<br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="参考：微信小程序双向数据绑定小程序双向绑定锅盖哒的博客-CSDN-博客"><a href="#参考：微信小程序双向数据绑定小程序双向绑定锅盖哒的博客-CSDN-博客" class="headerlink" title="参考：微信小程序双向数据绑定小程序双向绑定锅盖哒的博客-CSDN 博客"></a>参考：<a target="_blank" rel="noopener" href="https://blog.csdn.net/A12536365214/article/details/131320188">微信小程序双向数据绑定<em>小程序双向绑定</em>锅盖哒的博客-CSDN 博客</a></h5></li>
<li><h5 id="即可实现简单的双向数据绑定（2023-08-04-早）"><a href="#即可实现简单的双向数据绑定（2023-08-04-早）" class="headerlink" title="即可实现简单的双向数据绑定（2023/08/04 早）"></a>即可实现简单的双向数据绑定（2023/08/04 早）</h5></li>
</ul>
<h2 id="生命周期函数"><a href="#生命周期函数" class="headerlink" title="生命周期函数"></a>生命周期函数</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">/**</span><br><span class="hljs-comment">   * 生命周期函数--监听页面加载</span><br><span class="hljs-comment">   */</span><br>  <span class="hljs-title function_">onLoad</span>(<span class="hljs-params">options</span>) &#123;<br><br>  &#125;,<br></code></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">/**</span><br><span class="hljs-comment">  * 生命周期函数--监听页面显示</span><br><span class="hljs-comment">  */</span><br> <span class="hljs-title function_">onShow</span>(<span class="hljs-params"></span>) &#123;<br>   <span class="hljs-title class_">Toast</span>(<span class="hljs-string">&quot;分类~&quot;</span>)<br> &#125;,<br></code></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 生命周期函数--监听页面隐藏</span><br><span class="hljs-comment"> */</span><br><span class="hljs-title function_">onHide</span>(<span class="hljs-params"></span>) &#123;<br><br>&#125;,<br></code></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 生命周期函数--监听页面卸载</span><br><span class="hljs-comment"> */</span><br><span class="hljs-title function_">onUnload</span>(<span class="hljs-params"></span>) &#123;<br><br>&#125;,<br></code></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 生命周期函数--监听页面初次渲染完成</span><br><span class="hljs-comment"> */</span><br><span class="hljs-title function_">onReady</span>(<span class="hljs-params"></span>) &#123;<br><br>&#125;,<br></code></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><code class="hljs js"><br><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 页面相关事件处理函数--监听用户下拉动作</span><br><span class="hljs-comment"> */</span><br><span class="hljs-title function_">onPullDownRefresh</span>(<span class="hljs-params"></span>) &#123;<br><br>&#125;,<br><br><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 页面上拉触底事件的处理函数</span><br><span class="hljs-comment"> */</span><br><span class="hljs-title function_">onReachBottom</span>(<span class="hljs-params"></span>) &#123;<br><br>&#125;,<br><br><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 用户点击右上角分享</span><br><span class="hljs-comment"> */</span><br><span class="hljs-title function_">onShareAppMessage</span>(<span class="hljs-params"></span>) &#123;<br><br>&#125;<br></code></pre></td></tr></table></figure>

<h2 id="路由跳转"><a href="#路由跳转" class="headerlink" title="路由跳转"></a>路由跳转</h2><ul>
<li><h5 id="官方提供的路由跳转有以下-5-种："><a href="#官方提供的路由跳转有以下-5-种：" class="headerlink" title="官方提供的路由跳转有以下 5 种："></a>官方提供的路由跳转有以下 5 种：</h5></li>
</ul>
<figure class="highlight mipsasm"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs mipsasm">wx.<span class="hljs-keyword">switchTab	</span>跳转到 tabBar 页面，并关闭其他所有非 tabBar 页面<br></code></pre></td></tr></table></figure>

<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs stylus">wx<span class="hljs-selector-class">.reLaunch</span>		关闭所有页面，打开到应用内的某个页面<br></code></pre></td></tr></table></figure>

<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs stylus">wx<span class="hljs-selector-class">.redirectTo</span>	关闭当前页面，跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面<br></code></pre></td></tr></table></figure>

<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs stylus">wx<span class="hljs-selector-class">.navigateTo</span>	保留当前页面，跳转到应用内的某个页面。但是不能跳到 tabbar 页面<br></code></pre></td></tr></table></figure>

<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs stylus">wx<span class="hljs-selector-class">.navigateBack</span>	关闭当前页面，返回上一页面或多级页面<br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="我们可以分析出在不同的业务场景下，使用怎样的路由跳转更合适："><a href="#我们可以分析出在不同的业务场景下，使用怎样的路由跳转更合适：" class="headerlink" title="我们可以分析出在不同的业务场景下，使用怎样的路由跳转更合适："></a>我们可以分析出在不同的业务场景下，使用怎样的路由跳转更合适：</h5></li>
<li><h5 id="wx-switchTab：支持跳转至-tabbar-页面"><a href="#wx-switchTab：支持跳转至-tabbar-页面" class="headerlink" title="wx.switchTab：支持跳转至 tabbar 页面"></a>wx.switchTab：支持跳转至 tabbar 页面</h5><ul>
<li>跳转至 tabbar 页，关闭其他所有非 tabBar 页面</li>
</ul>
</li>
<li><h5 id="wx-redirectTo、wx-navigateTo：支持跳转至非-tabbar-页面"><a href="#wx-redirectTo、wx-navigateTo：支持跳转至非-tabbar-页面" class="headerlink" title="wx.redirectTo、wx.navigateTo：支持跳转至非 tabbar 页面"></a>wx.redirectTo、wx.navigateTo：支持跳转至非 tabbar 页面</h5><ul>
<li>前者关闭当前页面，后者保留当前页面</li>
<li>wx.navigateBack：与 wx.navigateTo 配合，返回上一级页面</li>
</ul>
</li>
<li><h5 id="wx-reLaunch：支持跳转至任何页面"><a href="#wx-reLaunch：支持跳转至任何页面" class="headerlink" title="wx.reLaunch：支持跳转至任何页面"></a>wx.reLaunch：支持跳转至任何页面</h5><ul>
<li>关闭所有页面，打开到应用内的某个页面</li>
</ul>
</li>
<li><h5 id="那么从登录页跳转至个人页，就应该用-wx-switchTab-wx-reLaunch（2023-08-05-早）"><a href="#那么从登录页跳转至个人页，就应该用-wx-switchTab-wx-reLaunch（2023-08-05-早）" class="headerlink" title="那么从登录页跳转至个人页，就应该用 wx.switchTab / wx.reLaunch（2023/08/05 早）"></a>那么从登录页跳转至个人页，就应该用 wx.switchTab / wx.reLaunch（2023/08/05 早）</h5></li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-title function_">goToLogin</span>(<span class="hljs-params"></span>) &#123;<br>   app.<span class="hljs-title function_">request</span>(&#123;<br>     <span class="hljs-attr">url</span>: <span class="hljs-string">&#x27;http://localhost:8084/api/user/login&#x27;</span>,<br>     <span class="hljs-attr">method</span>: <span class="hljs-string">&#x27;POST&#x27;</span>,<br>     <span class="hljs-attr">data</span>: &#123;<br>       <span class="hljs-attr">username</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">data</span>.<span class="hljs-property">username</span>,<br>       <span class="hljs-attr">password</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">data</span>.<span class="hljs-property">password</span>,<br>     &#125;,<br>     <span class="hljs-attr">success</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">res</span>) &#123;<br>       <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(res)<br>       <span class="hljs-keyword">const</span> data = res.<span class="hljs-property">data</span>;<br><br>       <span class="hljs-keyword">if</span> (data.<span class="hljs-property">code</span> == <span class="hljs-number">0</span>) &#123;<br>         <span class="hljs-comment">// 设置sessionID到缓存</span><br>         wx.<span class="hljs-title function_">setStorageSync</span>(<span class="hljs-string">&#x27;sessionID&#x27;</span>, res.<span class="hljs-property">header</span>[<span class="hljs-string">&quot;Set-Cookie&quot;</span>]);<br>         <span class="hljs-title class_">Notify</span>(&#123; <span class="hljs-attr">type</span>: <span class="hljs-string">&#x27;success&#x27;</span>, <span class="hljs-attr">message</span>: data.<span class="hljs-property">description</span> &#125;);<br>         wx.<span class="hljs-title function_">reLaunch</span>(&#123;<br>           <span class="hljs-attr">url</span>: <span class="hljs-string">&#x27;/pages/user/index&#x27;</span><br>         &#125;)<br>       &#125; <span class="hljs-keyword">else</span> &#123;<br>         <span class="hljs-title class_">Notify</span>(&#123; <span class="hljs-attr">type</span>: <span class="hljs-string">&#x27;warning&#x27;</span>, <span class="hljs-attr">message</span>: data.<span class="hljs-property">description</span> &#125;);<br>       &#125;<br>     &#125;,<br>     <span class="hljs-attr">fail</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">error</span>) &#123;<br>       <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(error);<br>     &#125;<br>   &#125;)<br> &#125;,<br></code></pre></td></tr></table></figure>

<h2 id="data-已初始化，未触发数据绑定"><a href="#data-已初始化，未触发数据绑定" class="headerlink" title="data 已初始化，未触发数据绑定"></a>data 已初始化，未触发数据绑定</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-title class_">Page</span>(&#123;<br>  <span class="hljs-attr">data</span>: &#123;<br>    <span class="hljs-attr">imgs</span>: [],<br>    <span class="hljs-attr">urlList</span>: []<br>  &#125;,<br></code></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><code class="hljs js"> <span class="hljs-comment">// 页面创建时执行</span><br>  <span class="hljs-title function_">onShow</span>(<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-title class_">Toast</span>(<span class="hljs-string">&quot;惊喜多多~&quot;</span>)<br>    <span class="hljs-keyword">var</span> _this = <span class="hljs-variable language_">this</span><br>    <span class="hljs-comment">// 获取壁纸</span><br>    app.<span class="hljs-title function_">request</span>(&#123;<br>      <span class="hljs-attr">url</span>: <span class="hljs-string">&#x27;http://localhost:8084/api/wallpaper/listPage&#x27;</span>,<br>      <span class="hljs-attr">method</span>: <span class="hljs-string">&#x27;GET&#x27;</span>,<br>      <span class="hljs-attr">success</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">res</span>) &#123;<br>        <span class="hljs-keyword">const</span> data = res.<span class="hljs-property">data</span>;<br>      <span class="hljs-comment">// 拿取到imgs列表</span><br>        _this.<span class="hljs-title function_">setData</span>(&#123;<br>          <span class="hljs-string">&#x27;imgs&#x27;</span>: data.<span class="hljs-property">data</span>.<span class="hljs-property">records</span><br>        &#125;);<br><span class="hljs-comment">// 拿取到urlList列表</span><br>        _this.<span class="hljs-property">data</span>.<span class="hljs-property">imgs</span>.<span class="hljs-title function_">forEach</span>(<span class="hljs-function">(<span class="hljs-params">item</span>) =&gt;</span> &#123;<br>          _this.<span class="hljs-property">data</span>.<span class="hljs-property">urlList</span>.<span class="hljs-title function_">push</span>(item.<span class="hljs-property">wallpaperUrl</span>); <br>        &#125;);<br>      &#125;,<br><br>      <span class="hljs-attr">fail</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">error</span>) &#123;<br>        <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(error);<br>      &#125;<br>    &#125;)<br>  &#125;,<br></code></pre></td></tr></table></figure>

<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">block</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;image-list&quot;</span> <span class="hljs-attr">wx:for</span>=<span class="hljs-string">&quot;&#123;&#123;urlList&#125;&#125;&quot;</span> <span class="hljs-attr">wx:key</span>=<span class="hljs-string">&quot;index&quot;</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">image</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;img&quot;</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;&#123;&#123;item&#125;&#125;&quot;</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">&quot;刚刚&quot;</span> <span class="hljs-attr">mode</span>=<span class="hljs-string">&quot;widthFix&quot;</span> /&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">block</span>&gt;</span><br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="这里的-image-标签，仍旧无法正常绑定到-urlList"><a href="#这里的-image-标签，仍旧无法正常绑定到-urlList" class="headerlink" title="这里的 image 标签，仍旧无法正常绑定到 urlList"></a>这里的 image 标签，仍旧无法正常绑定到 urlList</h5></li>
<li><h5 id="当-show-生命周期函数未执行完毕，即-urlList-仍为空数组时，data-在页面展示时已经初始化"><a href="#当-show-生命周期函数未执行完毕，即-urlList-仍为空数组时，data-在页面展示时已经初始化" class="headerlink" title="当 show()生命周期函数未执行完毕，即 urlList 仍为空数组时，data 在页面展示时已经初始化"></a>当 show()生命周期函数未执行完毕，即 urlList 仍为空数组时，data 在页面展示时已经初始化</h5></li>
<li><h5 id="如此改造-show-生命周期函数："><a href="#如此改造-show-生命周期函数：" class="headerlink" title="如此改造 show()生命周期函数："></a>如此改造 show()生命周期函数：</h5></li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// 页面创建时执行</span><br><span class="hljs-title function_">onShow</span>(<span class="hljs-params"></span>) &#123;<br>  <span class="hljs-title class_">Toast</span>(<span class="hljs-string">&quot;惊喜多多~&quot;</span>)<br>  <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">getData</span>();<br>&#125;,<br><span class="hljs-comment">// 获取imgs列表</span><br><span class="hljs-title function_">getData</span>(<span class="hljs-params"></span>) &#123;<br>  <span class="hljs-keyword">var</span> _this = <span class="hljs-variable language_">this</span>;<br>  <span class="hljs-comment">// 获取壁纸</span><br>  app.<span class="hljs-title function_">request</span>(&#123;<br>    <span class="hljs-attr">url</span>: <span class="hljs-string">&#x27;http://localhost:8084/api/wallpaper/listPage&#x27;</span>,<br>    <span class="hljs-attr">method</span>: <span class="hljs-string">&#x27;GET&#x27;</span>,<br>    <span class="hljs-attr">success</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">res</span>) &#123;<br>      <span class="hljs-keyword">const</span> data = res.<span class="hljs-property">data</span>;<br>      _this.<span class="hljs-title function_">setData</span>(&#123;<br>        <span class="hljs-string">&#x27;imgs&#x27;</span>: data.<span class="hljs-property">data</span>.<span class="hljs-property">records</span><br>      &#125;);<br>      _this.<span class="hljs-title function_">setUrlList</span>();<br>    &#125;<br>  &#125;);<br>&#125;,<br><span class="hljs-comment">// 获取url列表</span><br><span class="hljs-title function_">setUrlList</span>(<span class="hljs-params"></span>) &#123;<br>  <span class="hljs-keyword">var</span> urlList = [];<br>  <span class="hljs-variable language_">this</span>.<span class="hljs-property">data</span>.<span class="hljs-property">imgs</span>.<span class="hljs-title function_">forEach</span>(<span class="hljs-function">(<span class="hljs-params">item</span>) =&gt;</span> &#123;<br>    urlList.<span class="hljs-title function_">push</span>(item.<span class="hljs-property">wallpaperUrl</span>);<br>  &#125;);<br>  <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">setData</span>(&#123;<br>    <span class="hljs-string">&#x27;urlList&#x27;</span>: urlList<br>  &#125;);<br>&#125;,<br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="成功解决-urlList-数据双向绑定问题（2023-08-05-早）"><a href="#成功解决-urlList-数据双向绑定问题（2023-08-05-早）" class="headerlink" title="成功解决 urlList 数据双向绑定问题（2023/08/05 早）"></a>成功解决 urlList 数据双向绑定问题（2023/08/05 早）</h5></li>
</ul>
<h2 id="无法获取-Session"><a href="#无法获取-Session" class="headerlink" title="无法获取 Session"></a>无法获取 Session</h2><ul>
<li><p><a target="_blank" rel="noopener" href="https://pythonjishu.com/kgaxhpjbuoqadde/">微信小程序后端无法保持 session 的原因及解决办法问题 - Python 技术站 (pythonjishu.com)</a></p>
</li>
<li><h5 id="这种方法是不好使的："><a href="#这种方法是不好使的：" class="headerlink" title="这种方法是不好使的："></a>这种方法是不好使的：</h5></li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// 注册</span><br> <span class="hljs-title function_">goToLogin</span>(<span class="hljs-params"></span>) &#123;<br>   app.<span class="hljs-title function_">request</span>(&#123;<br>     <span class="hljs-attr">url</span>: <span class="hljs-string">&#x27;http://localhost:8084/api/user/login&#x27;</span>,<br>     <span class="hljs-attr">method</span>: <span class="hljs-string">&#x27;POST&#x27;</span>,<br>     <span class="hljs-attr">data</span>: &#123;<br>       <span class="hljs-attr">username</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">data</span>.<span class="hljs-property">username</span>,<br>       <span class="hljs-attr">password</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">data</span>.<span class="hljs-property">password</span>,<br>     &#125;,<br>     <span class="hljs-attr">success</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">res</span>) &#123;<br>       <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(res)<br>       <span class="hljs-keyword">const</span> data = res.<span class="hljs-property">data</span>;<br><br>       <span class="hljs-keyword">if</span> (data.<span class="hljs-property">code</span> == <span class="hljs-number">0</span>) &#123;<br>         <span class="hljs-comment">// 设置sessionID到缓存</span><br>         wx.<span class="hljs-title function_">setStorageSync</span>(<span class="hljs-string">&#x27;sessionID&#x27;</span>, res.<span class="hljs-property">header</span>[<span class="hljs-string">&quot;Set-Cookie&quot;</span>]);<br>         <span class="hljs-title class_">Notify</span>(&#123; <span class="hljs-attr">type</span>: <span class="hljs-string">&#x27;success&#x27;</span>, <span class="hljs-attr">message</span>: data.<span class="hljs-property">description</span> &#125;);<br>         wx.<span class="hljs-title function_">reLaunch</span>(&#123;<br>           <span class="hljs-attr">url</span>: <span class="hljs-string">&#x27;/pages/user/index&#x27;</span><br>         &#125;)<br>       &#125; <span class="hljs-keyword">else</span> &#123;<br>         <span class="hljs-title class_">Notify</span>(&#123; <span class="hljs-attr">type</span>: <span class="hljs-string">&#x27;warning&#x27;</span>, <span class="hljs-attr">message</span>: data.<span class="hljs-property">description</span> &#125;);<br>       &#125;<br>     &#125;,<br>     <span class="hljs-attr">fail</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">error</span>) &#123;<br>       <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(error);<br>     &#125;<br>   &#125;)<br> &#125;,<br></code></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs js">app.<span class="hljs-title function_">request</span>(&#123;<br>      <span class="hljs-attr">url</span>: <span class="hljs-string">&#x27;http://localhost:8084/api/user/current&#x27;</span>,<br>      <span class="hljs-attr">method</span>: <span class="hljs-string">&#x27;GET&#x27;</span>,<br>      <span class="hljs-attr">header</span>: &#123;<br>        <span class="hljs-string">&#x27;Content-Type&#x27;</span>: <span class="hljs-string">&#x27;application/json&#x27;</span>,<br>        <span class="hljs-string">&#x27;sessionID&#x27;</span>: wx.<span class="hljs-title function_">getStorageSync</span>(<span class="hljs-string">&#x27;sessionID&#x27;</span>)<br>      &#125;,<br>      <span class="hljs-attr">success</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">data</span>) &#123;<br>        <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(data);<br>      &#125;,<br>      <span class="hljs-attr">fail</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">error</span>) &#123;<br>        <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(error);<br>      &#125;<br>    &#125;)<br>  &#125;,<br></code></pre></td></tr></table></figure>

<h2 id="小程序登录-用户身份标识"><a href="#小程序登录-用户身份标识" class="headerlink" title="小程序登录 - 用户身份标识"></a>小程序登录 - 用户身份标识</h2><ul>
<li><h5 id="这里讲一下在微信小程序开发过程中，如何做到记录用户登录态，标识用户身份（2023-08-06-早）"><a href="#这里讲一下在微信小程序开发过程中，如何做到记录用户登录态，标识用户身份（2023-08-06-早）" class="headerlink" title="这里讲一下在微信小程序开发过程中，如何做到记录用户登录态，标识用户身份（2023/08/06 早）"></a>这里讲一下在微信小程序开发过程中，如何做到记录用户登录态，标识用户身份（2023/08/06 早）</h5></li>
<li><p><a target="_blank" rel="noopener" href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/user-login/code2Session.html">小程序登录 / 小程序登录 | 小程序登录 | 微信开放文档 (qq.com)</a></p>
</li>
<li><p><a target="_blank" rel="noopener" href="https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html">开放能力 / 用户信息 / 小程序登录 | 小程序登录 | 微信开放文档 (qq.com)</a></p>
</li>
<li><p><a target="_blank" rel="noopener" href="https://www.hutool.cn/docs/#/http/Http%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%B7%A5%E5%85%B7%E7%B1%BB-HttpUtil">Http 客户端工具类-HttpUtil (hutool.cn)</a></p>
</li>
<li><h5 id="整个流程如下："><a href="#整个流程如下：" class="headerlink" title="整个流程如下："></a>整个流程如下：</h5><ul>
<li><p>前台获取临时登录凭证 code</p>
</li>
<li><p>发送 code 到服务端</p>
</li>
<li><p>服务端拿到 code，通过 code 调用 Code3Session 接口，获取 openid、session_key</p>
</li>
<li><p>服务端返回 openid、session_key 到前台</p>
</li>
<li><p>前台拿到 openid、session_key，作为 token</p>
</li>
<li><p>之后，前台发送请求，携带 token</p>
</li>
<li><p>服务器通过校验 token，选择是否响应该请求</p>
</li>
</ul>
</li>
<li><h5 id="前台发送-code-到服务端："><a href="#前台发送-code-到服务端：" class="headerlink" title="前台发送 code 到服务端："></a>前台发送 code 到服务端：</h5></li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// 登录</span><br>  <span class="hljs-title function_">goToLogin</span>(<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-keyword">var</span> _this = <span class="hljs-variable language_">this</span>;<br>    wx.<span class="hljs-title function_">login</span>(&#123;<br>      <span class="hljs-title function_">success</span>(<span class="hljs-params">res</span>) &#123;<br>        <span class="hljs-keyword">if</span> (res.<span class="hljs-property">code</span>) &#123;<br>          <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&quot;code = &quot;</span> + res.<span class="hljs-property">code</span>)<br>          <span class="hljs-comment">//发起网络请求</span><br>          wx.<span class="hljs-title function_">request</span>(&#123;<br>            <span class="hljs-attr">url</span>: <span class="hljs-string">&#x27;http://localhost:8084/api/user/login&#x27;</span>,<br>            <span class="hljs-attr">method</span>: <span class="hljs-string">&#x27;POST&#x27;</span>,<br>            <span class="hljs-attr">data</span>: &#123;<br>              <span class="hljs-attr">code</span>: res.<span class="hljs-property">code</span>,<br>              <span class="hljs-attr">username</span>: _this.<span class="hljs-property">data</span>.<span class="hljs-property">username</span>,<br>              <span class="hljs-attr">password</span>: _this.<span class="hljs-property">data</span>.<span class="hljs-property">password</span>,<br>            &#125;,<br>            <span class="hljs-attr">success</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">res</span>) &#123;<br>              <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(res)<br>              <span class="hljs-keyword">const</span> data = res.<span class="hljs-property">data</span>;<br><br>              <span class="hljs-keyword">if</span> (data.<span class="hljs-property">code</span> == <span class="hljs-number">0</span>) &#123;<br>                <span class="hljs-comment">// 设置sessionID到缓存</span><br>                <span class="hljs-title class_">Notify</span>(&#123; <span class="hljs-attr">type</span>: <span class="hljs-string">&#x27;success&#x27;</span>, <span class="hljs-attr">message</span>: data.<span class="hljs-property">description</span> &#125;);<br>                wx.<span class="hljs-title function_">reLaunch</span>(&#123;<br>                  <span class="hljs-attr">url</span>: <span class="hljs-string">&#x27;/pages/user/index&#x27;</span><br>                &#125;)<br>              &#125; <span class="hljs-keyword">else</span> &#123;<br>                <span class="hljs-title class_">Notify</span>(&#123; <span class="hljs-attr">type</span>: <span class="hljs-string">&#x27;warning&#x27;</span>, <span class="hljs-attr">message</span>: data.<span class="hljs-property">description</span> &#125;);<br>              &#125;<br>            &#125;,<br>            <span class="hljs-attr">fail</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">error</span>) &#123;<br>              <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(error);<br>            &#125;<br>          &#125;)<br>        &#125; <span class="hljs-keyword">else</span> &#123;<br>          <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&#x27;登录失败！&#x27;</span> + res.<span class="hljs-property">errMsg</span>)<br>        &#125;<br>      &#125;<br>    &#125;)<br>  &#125;,<br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="后台："><a href="#后台：" class="headerlink" title="后台："></a>后台：</h5></li>
<li><p>服务端拿到 code，通过 code 调用 Code3Session 接口，获取 openid、session_key</p>
</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> <span class="hljs-type">String</span> <span class="hljs-variable">appId</span> <span class="hljs-operator">=</span> <span class="hljs-string">&quot;wxd12f7c79bd639a9b&quot;</span>;<br><span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> <span class="hljs-type">String</span> <span class="hljs-variable">secret</span> <span class="hljs-operator">=</span> <span class="hljs-string">&quot;8a99ccc1802486c1387c1cda45288dd5&quot;</span>;<br></code></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><code class="hljs java"> <span class="hljs-keyword">public</span> String <span class="hljs-title function_">getCode2Session</span><span class="hljs-params">(String appId, String secret, String code)</span> &#123;<br>     <span class="hljs-type">String</span> <span class="hljs-variable">url</span> <span class="hljs-operator">=</span> String.format(<span class="hljs-string">&quot;https://api.weixin.qq.com/sns/jscode2session?appid=%s&amp;secret=%s&amp;js_code=%s&amp;grant_type=authorization_code&quot;</span>, appId, secret, code);<br><br>     <span class="hljs-type">HttpRequest</span> <span class="hljs-variable">request</span> <span class="hljs-operator">=</span> HttpRequest.get(url);<br>     log.info(<span class="hljs-string">&quot;result = &quot;</span> + request.execute());<br>     <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;request&quot;</span>;<br> &#125;<br><br> <span class="hljs-comment">/** 后台也可以这样写 **/</span><br><br><span class="hljs-type">String</span> <span class="hljs-variable">url</span> <span class="hljs-operator">=</span> <span class="hljs-string">&quot;https://api.weixin.qq.com/sns/jscode2session&quot;</span>;<br>     HashMap&lt;String, Object&gt; paramMap = <span class="hljs-keyword">new</span> <span class="hljs-title class_">HashMap</span>&lt;&gt;();<br>     paramMap.put(<span class="hljs-string">&quot;appid&quot;</span>, appId);<br>     paramMap.put(<span class="hljs-string">&quot;secret&quot;</span>, secret);<br>     paramMap.put(<span class="hljs-string">&quot;js_code&quot;</span>, code);<br>     paramMap.put(<span class="hljs-string">&quot;grant_type&quot;</span>, <span class="hljs-string">&quot;authorization_code&quot;</span>);<br>     <span class="hljs-type">String</span> <span class="hljs-variable">result</span> <span class="hljs-operator">=</span> HttpUtil.get(url, paramMap);<br>     log.info(<span class="hljs-string">&quot;result = &quot;</span> + result);<br>     <span class="hljs-keyword">return</span> result;<br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="成功："><a href="#成功：" class="headerlink" title="成功："></a>成功：</h5></li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash">Response Body:<br>    &#123;<span class="hljs-string">&quot;session_key&quot;</span>:<span class="hljs-string">&quot;oZ0ju27QocpPhHF2Z1MrtQ==&quot;</span>,<span class="hljs-string">&quot;openid&quot;</span>:<span class="hljs-string">&quot;otcWC6_yPHlB2Q6e0vIrB_J2iYHs&quot;</span>&#125;<br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="失败"><a href="#失败" class="headerlink" title="失败"></a>失败</h5></li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">&#123;<span class="hljs-string">&quot;errcode&quot;</span>:40029,<span class="hljs-string">&quot;errmsg&quot;</span>:<span class="hljs-string">&quot;invalid code, rid: 64cf07f9-36a4c687-09c960f0&quot;</span>&#125;<br></code></pre></td></tr></table></figure>

<ul>
<li><p>服务端返回 openid、session_key 到前台</p>
</li>
<li></li>
<li><p>前台拿到 openid、session_key，作为 token</p>
</li>
<li><p>之后，前台发送请求，携带 token</p>
</li>
<li></li>
<li><p>服务器通过校验 token，选择是否响应该请求</p>
</li>
</ul>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs javascript">onShow () &#123;<br>  <span class="hljs-title class_">Toast</span>(<span class="hljs-string">&#x27;个人中心~&#x27;</span>);<br>  <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&quot;seeesion_key = &quot;</span> + wx.<span class="hljs-title function_">getStorageSync</span>(<span class="hljs-string">&#x27;session_key&#x27;</span>))<br><br>  app.<span class="hljs-title function_">request</span>(&#123;<br>    <span class="hljs-attr">url</span>: <span class="hljs-string">&#x27;http://localhost:8084/api/user/current&#x27;</span>,<br>    <span class="hljs-attr">method</span>: <span class="hljs-string">&#x27;GET&#x27;</span>,<br>    <span class="hljs-attr">header</span>: &#123;<br>      <span class="hljs-string">&#x27;Authorization&#x27;</span>: <span class="hljs-string">&#x27;Bearer &#x27;</span> + wx.<span class="hljs-title function_">getStorageSync</span>(<span class="hljs-string">&#x27;session_key&#x27;</span>)<br>    &#125;,<br>    <span class="hljs-attr">success</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">data</span>) &#123;<br>      <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(data);<br>    &#125;,<br>    <span class="hljs-attr">fail</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">error</span>) &#123;<br>      <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(error);<br>    &#125;<br>  &#125;)<br>&#125;,<br></code></pre></td></tr></table></figure>

<h2 id="路由跳转、携带参数"><a href="#路由跳转、携带参数" class="headerlink" title="路由跳转、携带参数"></a>路由跳转、携带参数</h2><ul>
<li><h5 id="首页跳转至壁纸详情页，携带-url-路径："><a href="#首页跳转至壁纸详情页，携带-url-路径：" class="headerlink" title="首页跳转至壁纸详情页，携带 url 路径："></a>首页跳转至壁纸详情页，携带 url 路径：</h5></li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// 跳转到壁纸详情页</span><br><span class="hljs-title function_">onClickShow</span>(<span class="hljs-params">e</span>) &#123;<br>  <span class="hljs-keyword">const</span> imageUrl = e.<span class="hljs-property">currentTarget</span>.<span class="hljs-property">dataset</span>.<span class="hljs-property">url</span>;<br>  <span class="hljs-keyword">const</span> parameter = &#123;<br>    <span class="hljs-attr">url</span>: imageUrl<br>  &#125;;<br>  <span class="hljs-keyword">const</span> url = <span class="hljs-string">&#x27;/pages/imageInfo/index?parameter=&#x27;</span> + <span class="hljs-built_in">encodeURIComponent</span>(<span class="hljs-title class_">JSON</span>.<span class="hljs-title function_">stringify</span>(parameter));<br>  wx.<span class="hljs-title function_">navigateTo</span>(&#123;<br>    <span class="hljs-attr">url</span>: url<br>  &#125;);<br>&#125;,<br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="壁纸详情页接收参数："><a href="#壁纸详情页接收参数：" class="headerlink" title="壁纸详情页接收参数："></a>壁纸详情页接收参数：</h5></li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 生命周期函数--监听页面加载</span><br><span class="hljs-comment"> */</span><br><span class="hljs-title function_">onLoad</span>(<span class="hljs-params">options</span>) &#123;<br>  <span class="hljs-keyword">const</span> &#123;url&#125; = <span class="hljs-title class_">JSON</span>.<span class="hljs-title function_">parse</span>(<span class="hljs-built_in">decodeURIComponent</span>(options.<span class="hljs-property">parameter</span>));<br>  <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(url)<br>  <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">getData</span>(url)<br>&#125;,<br><br><span class="hljs-comment">// 获取壁纸url</span><br><span class="hljs-title function_">getData</span>(<span class="hljs-params">url</span>)&#123;<br>  <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">setData</span>(&#123;<br>    <span class="hljs-string">&#x27;url&#x27;</span>: url<br>  &#125;)<br>  <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">data</span>.<span class="hljs-property">url</span>)<br>&#125;,<br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="要注意这里的-options-拿到的数据是封装好的对象，要使用如上方式接收参数：（2023-08-09-晚）"><a href="#要注意这里的-options-拿到的数据是封装好的对象，要使用如上方式接收参数：（2023-08-09-晚）" class="headerlink" title="要注意这里的 options 拿到的数据是封装好的对象，要使用如上方式接收参数：（2023/08/09 晚）"></a>要注意这里的 options 拿到的数据是封装好的对象，要使用如上方式接收参数：（2023/08/09 晚）</h5></li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">const</span> &#123; url &#125; = <span class="hljs-title class_">JSON</span>.<span class="hljs-title function_">parse</span>(<span class="hljs-built_in">decodeURIComponent</span>(options.<span class="hljs-property">parameter</span>));<br></code></pre></td></tr></table></figure>

<h2 id="点击-image-标签携带-URL"><a href="#点击-image-标签携带-URL" class="headerlink" title="点击 image 标签携带 URL"></a>点击 image 标签携带 URL</h2><ul>
<li><h5 id="要给每个-lt-image-gt-标签添加-click-函数，以便点击不同的图片跳转到不同的页面，可以通过以下方法实现："><a href="#要给每个-lt-image-gt-标签添加-click-函数，以便点击不同的图片跳转到不同的页面，可以通过以下方法实现：" class="headerlink" title="要给每个 &lt;image&gt; 标签添加 click 函数，以便点击不同的图片跳转到不同的页面，可以通过以下方法实现："></a>要给每个 <code>&lt;image&gt;</code> 标签添加 click 函数，以便点击不同的图片跳转到不同的页面，可以通过以下方法实现：</h5></li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">image</span></span><br><span class="hljs-tag">  <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;img&quot;</span></span><br><span class="hljs-tag">  <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;&#123;&#123;item&#125;&#125;&quot;</span></span><br><span class="hljs-tag">  <span class="hljs-attr">alt</span>=<span class="hljs-string">&quot;刚刚&quot;</span></span><br><span class="hljs-tag">  <span class="hljs-attr">mode</span>=<span class="hljs-string">&quot;widthFix&quot;</span></span><br><span class="hljs-tag">  <span class="hljs-attr">bindtap</span>=<span class="hljs-string">&quot;handleImageTap&quot;</span></span><br><span class="hljs-tag">  <span class="hljs-attr">data-url</span>=<span class="hljs-string">&quot;&#123;&#123;item&#125;&#125;&quot;</span></span><br><span class="hljs-tag">/&gt;</span><br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="在当前页面的-JS-文件中定义-handleImageTap-方法来处理点击事件"><a href="#在当前页面的-JS-文件中定义-handleImageTap-方法来处理点击事件" class="headerlink" title="在当前页面的 JS 文件中定义 handleImageTap 方法来处理点击事件"></a>在当前页面的 JS 文件中定义 <code>handleImageTap</code> 方法来处理点击事件</h5></li>
<li><h5 id="可以使用-wx-navigateTo-方法跳转到不同的页面并传递参数"><a href="#可以使用-wx-navigateTo-方法跳转到不同的页面并传递参数" class="headerlink" title="可以使用 wx.navigateTo 方法跳转到不同的页面并传递参数"></a>可以使用 <code>wx.navigateTo</code> 方法跳转到不同的页面并传递参数</h5></li>
</ul>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-title class_">Page</span>(&#123;<br>  <span class="hljs-title function_">handleImageTap</span>(<span class="hljs-params">e</span>) &#123;<br>    <span class="hljs-keyword">const</span> imageUrl = e.<span class="hljs-property">currentTarget</span>.<span class="hljs-property">dataset</span>.<span class="hljs-property">url</span>;<br>    <span class="hljs-comment">// 根据需要的逻辑处理点击事件，例如根据不同的 imageUrl 进行不同的跳转</span><br>    wx.<span class="hljs-title function_">navigateTo</span>(&#123;<br>      <span class="hljs-attr">url</span>: <span class="hljs-string">`/pages/detail?imageUrl=\$&#123;imageUrl&#125;`</span>,<br>    &#125;);<br>  &#125;,<br>&#125;);<br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="在-handleImageTap-方法中，使用-e-currentTarget-dataset-url-获取到点击的图片链接，然后根据需要的逻辑进行不同的跳转。"><a href="#在-handleImageTap-方法中，使用-e-currentTarget-dataset-url-获取到点击的图片链接，然后根据需要的逻辑进行不同的跳转。" class="headerlink" title="在 handleImageTap 方法中，使用 e.currentTarget.dataset.url 获取到点击的图片链接，然后根据需要的逻辑进行不同的跳转。"></a>在 <code>handleImageTap</code> 方法中，使用 <code>e.currentTarget.dataset.url</code> 获取到点击的图片链接，然后根据需要的逻辑进行不同的跳转。</h5></li>
<li><h5 id="请注意，上述代码是使用小程序原生的-wx-navigateTo-进行页面跳转，如果你使用的是框架或组件库，可能有不同的方法来实现页面跳转。（2023-08-09-晚）"><a href="#请注意，上述代码是使用小程序原生的-wx-navigateTo-进行页面跳转，如果你使用的是框架或组件库，可能有不同的方法来实现页面跳转。（2023-08-09-晚）" class="headerlink" title="请注意，上述代码是使用小程序原生的 wx.navigateTo 进行页面跳转，如果你使用的是框架或组件库，可能有不同的方法来实现页面跳转。（2023/08/09 晚）"></a>请注意，上述代码是使用小程序原生的 <code>wx.navigateTo</code> 进行页面跳转，如果你使用的是框架或组件库，可能有不同的方法来实现页面跳转。（2023/08/09 晚）</h5></li>
</ul>
<h2 id="实现点赞图片"><a href="#实现点赞图片" class="headerlink" title="实现点赞图片"></a>实现点赞图片</h2><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-comment">&lt;!-- 点赞量 --&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">view</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;like&quot;</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">van-icon</span></span><br><span class="hljs-tag">    <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;&#123;&#123;isLiked ? &#x27;like&#x27; : &#x27;like-o&#x27;&#125;&#125;&quot;</span></span><br><span class="hljs-tag">    <span class="hljs-attr">color</span>=<span class="hljs-string">&quot;red&quot;</span></span><br><span class="hljs-tag">    <span class="hljs-attr">bindtap</span>=<span class="hljs-string">&quot;handleIconClick&quot;</span></span><br><span class="hljs-tag">  /&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">view</span>&gt;</span><br></code></pre></td></tr></table></figure>

<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-comment">// 点赞壁纸</span><br> <span class="hljs-title function_">handleIconClick</span>(<span class="hljs-params"></span>) &#123;<br>   <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">setData</span>(&#123;<br>     <span class="hljs-attr">isLiked</span>: !<span class="hljs-variable language_">this</span>.<span class="hljs-property">data</span>.<span class="hljs-property">isLiked</span>, <span class="hljs-comment">// 点击后取反</span><br>   &#125;);<br>   <span class="hljs-keyword">if</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">data</span>.<span class="hljs-property">isLiked</span>)&#123;<br>     <span class="hljs-title class_">Toast</span>(<span class="hljs-string">&quot;已收藏~&quot;</span>)<br>   &#125;<span class="hljs-keyword">else</span>&#123;<br>     <span class="hljs-title class_">Toast</span>(<span class="hljs-string">&#x27;取消收藏~&#x27;</span>)<br>   &#125;<br> &#125;,<br></code></pre></td></tr></table></figure>

<h2 id="效果呈现"><a href="#效果呈现" class="headerlink" title="效果呈现"></a>效果呈现</h2><blockquote>
<p>2024 年 4 月 22 日</p>
</blockquote>
<p>半年前尝试开发过第一个微信小程序，花费了二十天时间认真做功能实现.。当时为了开发这个小程序，还借鉴了不少相关小程序的页面排版，多方参照才最终定型了这版页面。那么最终的<strong>效果如下</strong>：</p>
<p><img src="http://blog.memory-life.xyz/image-20230908221852633.png" alt="image-20230908221852633"></p>
<p><img src="http://blog.memory-life.xyz/image-20230908221858146.png" alt="image-20230908221858146"></p>
<p><img src="http://blog.memory-life.xyz/image-20230908221905369.png" alt="image-20230908221905369"></p>
<h2 id="踩坑记录"><a href="#踩坑记录" class="headerlink" title="踩坑记录"></a>踩坑记录</h2><ul>
<li><h5 id="首先，能够正确获取到小程序的-appID、appSecret："><a href="#首先，能够正确获取到小程序的-appID、appSecret：" class="headerlink" title="首先，能够正确获取到小程序的 appID、appSecret："></a>首先，能够正确获取到小程序的 appID、appSecret：</h5></li>
</ul>
<p><img src="http://blog.memory-life.xyz/image-20230806111056970.png" alt="image-20230806111056970"></p>
<ul>
<li><h5 id="开发者工具的-appID-必须设置正确，否则会不可避免地出现-invalid-code-错误：（2023-08-06-早）"><a href="#开发者工具的-appID-必须设置正确，否则会不可避免地出现-invalid-code-错误：（2023-08-06-早）" class="headerlink" title="开发者工具的 appID 必须设置正确，否则会不可避免地出现 invalid code 错误：（2023/08/06 早）"></a>开发者工具的 appID 必须设置正确，否则会不可避免地出现 invalid code 错误：（2023/08/06 早）</h5></li>
</ul>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs json"><span class="hljs-punctuation">&#123;</span><span class="hljs-attr">&quot;errcode&quot;</span><span class="hljs-punctuation">:</span><span class="hljs-number">40029</span><span class="hljs-punctuation">,</span><span class="hljs-attr">&quot;errmsg&quot;</span><span class="hljs-punctuation">:</span><span class="hljs-string">&quot;invalid code, rid: 64cf07f9-36a4c687-09c960f0&quot;</span><span class="hljs-punctuation">&#125;</span><br></code></pre></td></tr></table></figure>

<p><img src="http://blog.memory-life.xyz/image-20230806110759499.png" alt="image-20230806110759499"></p>
<h1 id="公众号开通"><a href="#公众号开通" class="headerlink" title="公众号开通"></a>公众号开通</h1><blockquote>
<p>2024 年 4 月 22 日</p>
</blockquote>
<p>今下午，我突然想要开通一个微信公众号，借此来激励我每天读书写作。那是因为最近开始慢慢回忆起<strong>小时候的乡村生活</strong>，写的东西渐渐多了起来。但总归是没时间没精力，写东西断断续续的，我对这样的写作现状很不满意。</p>
<p>于是下午看了很多相关公众号文章，计划近段时间就开启公众号文章写作计划：</p>
<p><img src="http://blog.memory-life.xyz/image-20240422153640539.png" alt="image-20240422153640539"></p>
<p>我快速回顾了前段时间里了解到的有关微信公众平台的信息，包括小程序开发、智能机器人对话（<a target="_blank" rel="noopener" href="https://www.nowcoder.com/discuss/353159057999601664?sourceSSR=users">动手做个 AI 机器人，帮我回消息！_牛客网 (nowcoder.com)</a>）这些，把这些快遗忘的知识捡起来。</p>
<p><strong>微信公众平台访问入口：<a target="_blank" rel="noopener" href="https://mp.weixin.qq.com/?token=&lang=zh_CN">微信公众平台 (qq.com)</a></strong></p>
<p>注册一个微信公众号，选择<strong>订阅号</strong>即可。</p>
<p><img src="http://blog.memory-life.xyz/image-20240422153221125.png" alt="image-20240422153221125"></p>
<p>但接下来的一步就让我止步于此了，我必须要提供一个<strong>未被微信公众平台注册过</strong>的邮箱</p>
<p><img src="http://blog.memory-life.xyz/image-20240422154009938.png" alt="image-20240422154009938"></p>
<p>详细要求可以看这里：<a target="_blank" rel="noopener" href="https://kf.qq.com/faq/120911VrYVrA161215zqaIJr.html">公众号注册提示“邮箱已被占用” (qq.com)</a></p>
<p>除了现在正在使用的 qq 邮箱外，去年写小程序时还用手机号申请了网易邮箱。但现在由于这个网易邮箱绑定了一个小程序，要想顺利开通微信公众号，目前只有两种解决办法：<strong>修改小程序登录邮箱</strong>和<strong>注销小程序</strong></p>
<p><img src="http://blog.memory-life.xyz/image-20240422144343165.png" alt="image-20240422144343165"></p>
<p>虽然这个小程序是废稿，但毕竟是我开发的第一个微信小程序，未来可能还要继续优化呢。就这么注销了的话，本地的开发可能受到影响，怪可惜的。那最终的解决办法就是：<strong>今天晚上回去找我兄弟，让他注册一个网易邮箱，完事了我把小程序邮箱账号更换成他的，我开通的微信公众号就绑定我的网易邮箱吧。</strong></p>
<p>那么现在就开始研究研究今年年初搞过的微信智能 AI 机器人了，不知道当时怎么想的，竟然没有记录下代码是如何起来的。相关的开发文档也没有多少记录，只有运行效果，只好是我再继续摸索摸索。</p>
<blockquote>
<p>2024 年 4 月 23 日</p>
</blockquote>
<p>很好，昨天下午总结了一番微信智能 AI 机器人的开发流程，晚上又让我的好兄弟注册了新的网易邮箱。</p>
<p>这下我就成功开通了微信公众号了。</p>
<h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1>
                
              </div>
            
            <hr/>
            <div>
              <!-- 文章页面 - 底部标签 -->
<div class="post-metas my-3">
  
  <div class="post-meta mr-3 d-flex align-items-center">
    <i class="iconfont icon-category"></i>
    <!-- 归档页 - 文章列表 -->


<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/blog/categories/%E4%BB%A3%E7%A0%81%E9%94%8B%E8%8A%92/" class="category-chain-item">代码锋芒</a>
  
  
    <span>></span>
    
  <a href="/blog/categories/%E4%BB%A3%E7%A0%81%E9%94%8B%E8%8A%92/%E9%A1%B9%E7%9B%AE%E5%BF%97%E5%BD%95/" class="category-chain-item">项目志录</a>
  
  

  

      </span>
    
  
</span>

  </div>
   
  <div class="post-meta">
    <i class="iconfont icon-tags"></i>
    
    <a href="/blog/tags/%E7%BB%8F%E9%AA%8C/">#经验</a>
    
    <a href="/blog/tags/%E9%A1%B9%E7%9B%AE/">#项目</a>
    
    <a href="/blog/tags/%E5%B0%8F%E7%A8%8B%E5%BA%8F/">#小程序</a>
    
  </div>
  
</div>


              <!-- 文章页面 - 底部标签下方 -->

  
  <div class="license-box my-3">
    <div class="license-title">
      <div>小程序开发经验分享：踩坑指南与技巧总结</div>
      <div>https://test.atomgit.net/blog/2023/07/30/小程序开发经验分享：踩坑指南与技巧总结/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>Memory</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2023年7月30日</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>更新于</div>
          <div>2025年7月3日</div>
        </div>
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/blog/2023/08/02/PicMemories%20%E5%A3%81%E7%BA%B8%E5%88%86%E4%BA%AB%E5%B0%8F%E7%A8%8B%E5%BA%8F%20-%20%E5%BC%80%E5%8F%91%E6%96%87%E6%A1%A3/" title="PicMemories-开发文档">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">PicMemories-开发文档</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/blog/2023/07/30/%E4%B8%80%E6%96%87%E6%90%9E%E5%AE%9A%E7%BD%91%E7%AB%99%E4%B8%8A%E7%BA%BF%EF%BC%9A%E4%BB%8E%E9%9B%B6%E5%88%B0%E4%B8%80%E7%9A%84%E5%AE%9E%E6%88%98%E6%8C%87%E5%8D%97/" title="一文搞定网站上线：从零到一的实战指南">
                        <span class="hidden-mobile">一文搞定网站上线：从零到一的实战指南</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            <!-- 文章页 - 评论上方 -->

  
  
    <article id="comments">
      
  <div id="valine"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#valine', function() {
      Fluid.utils.createScript('https://cdn.jsdelivr.net/gh/HCLonely/Valine@latest/dist/Valine.min.js', function() {
        var options = Object.assign(
          {"appId":"T1hUHH9Ks1ggG9DBE3HgUPpV-gzGzoHsz","appKey":"XFkgzzvzNo3J3uNCbBiSOFKc","path":"window.location.pathname","placeholder":"填取QQ号和邮箱后评论，支持读取头像及消息提醒，留下点什么叭... ᶘ ᵒᴥᵒᶅ","avatar":"Gravatar","meta":["nick","mail","link"],"requiredFields":[],"pageSize":10,"lang":"zh-CN","highlight":true,"recordIP":false,"serverURLs":"https://t1huhh9k.lc-cn-n1-shared.com","emojiCDN":null,"emojiMaps":null,"enableQQ":true,"master":"8c9b6d6637904da62d74d019cc6982de","friends":"0188229a9cfc284176ea9135cb9514cc","visitor":true},
          {
            el: "#valine",
            path: window.location.pathname,
            app_id: "",
            app_key: "",
            placeholder: "填取QQ号和邮箱后评论，支持读取头像及消息提醒，留下点什么叭... ᶘ ᵒᴥᵒᶅ",
            avatar: "Gravatar",
            meta: ["nick","mail","link"],
            pageSize: "10",
            lang: "zh-CN",
            highlight: true,
            recordIP: false,
            serverURLs: "https://t1huhh9k.lc-cn-n1-shared.com",

            // 设置Bilibili表情包地址
            emojiCDN: '//i0.hdslb.com/bfs/emote/', 
            // 表情title和图片映射
            emojiMaps: {
                "tv_白眼": "48f75163437445665a9be80bb316e4cb252c5415.gif@48w_48h.webp",
                "tv_doge": "302d6c88c63ed162c81a49cafe7ed2709e6fb955.gif@48w_48h.webp",
                "tv_坏笑": "5d2572efd09aab5dde9e2a198bb3f9ac1e2a982e.gif@48w_48h.webp",
                "tv_难过": "9c6b41008a67755410f712334c64313df5f91b3f.gif@48w_48h.webp",
                "tv_生气": "1902a5a2df5b5c931d88c12f0feb264b1e109d0d.gif@48w_48h.webp",
                "tv_委屈": "af5a5853edb43a8178a8cb5df707fa5e88143699.gif@48w_48h.webp",
                "tv_斜眼笑": "c66568b471192ca1f62f6ed4384dc1b283ab7508.gif@48w_48h.webp",
                "tv_呆": "d3fa91e4db9215eb1e20ab9da44f1214aa4bda7b.gif@48w_48h.webp",
                "tv_发怒": "3959eb81b952e4fa8d269d98f9e3639172d84073.gif@48w_48h.webp",
                "tv_呕吐": "db58e9442aae26694af18cc1683607cca3a16763.gif@48w_48h.webp",
                "tv_思考": "b63f9146bfd985af014f8d6d4bdb498805be48f9.gif@48w_48h.webp",
                "tv_微笑": "b98656855d782f61cb8edc7f7fca6563ecafff7e.gif@48w_48h.webp",
                "tv_疑问": "fce1b1a0f3b0e39a2dc16a18508dba7b91e929f4.gif@48w_48h.webp",
                "tv_大哭": "cba61f05f3039b02a7ffc0dfcd9d7995df9fdd74.gif@48w_48h.webp",
                "tv_鼓掌": "be106e6b265883a9f28fbe10f7b765701e2618d4.gif@48w_48h.webp",
                "tv_抠鼻": "696d9f93e722144dc2a78aeffc569418fdf3d565.gif@48w_48h.webp",
                "tv_亲亲": "3534ea44ab74bd20352b88c245a06c4b4c46d271.gif@48w_48h.webp",
                "tv_调皮": "fcd967395fd14e4dd5829fa7e8a967ce23205e52.gif@48w_48h.webp",
                "tv_笑哭": "1c2fd1e8c9dde12812f86e5d4cbddd8993d98082.gif@48w_48h.webp",
                "tv_晕": "030040ec5c9ddc9e3d067658c4139e7314ab42f8.gif@48w_48h.webp",
                "tv_点赞": "30ecff401245fb56bcc1cf588d1809ac1ab1607c.gif@48w_48h.webp",
                "tv_害羞": "411a3e459e8580f5bfd9f639a408247c4b509935.gif@48w_48h.webp",
                "tv_睡着": "3c8b5e293261287a6203597e29b3de07df4d18c6.gif@48w_48h.webp",
                "tv_色": "a0c6d99ab0ab63b8648f5283ff72cec04b604828.gif@48w_48h.webp",
                "tv_吐血": "e17e4539e169d14a3389ff147afea760cebe5de5.gif@48w_48h.webp",
                "tv_无奈": "eb4cb5f07cfd177c7e6a7914316717e56d9cc1d0.gif@48w_48h.webp",
                "tv_再见": "344f61609ecce2008520dc8a977b6169215748a9.gif@48w_48h.webp",
                "tv_流汗": "390bccec65eaff536bd5bb2a0c5b8b0bdea47334.gif@48w_48h.webp",
                "tv_偷笑": "7f11e6f7f63e79112b833bd41fa13a83d7cd8474.gif@48w_48h.webp",
                "tv_抓狂":"a476b93ecd8e94ac3257323fd822f91cef212de2.gif@48w_48h.webp",
                "tv_黑人问号":"b609adf664be33224a9923262031165ae3e34cd2.gif@48w_48h.webp",
                "tv_困":"91c2bf34ecf842d7016c01d841db3d4074bd281f.gif@48w_48h.webp",
                "tv_打脸":"b0fad4856e59c1240e448437da3287bb5ce547e5.gif@48w_48h.webp",
                "tv_闭嘴":"a3fc5388b09e945be3f18fe23bfed5874a0285b7.gif@48w_48h.webp",
                "tv_鄙视":"293b5d459e6264ecf314d20937a936fa672ccd1e.gif@48w_48h.webp",
                "tv_腼腆":"30984e8264324f901d19bea85dada7103b695534.gif@48w_48h.webp",
                "tv_馋":"2525c5703c594e5f0752f68db8948773caebde47.gif@48w_48h.webp",
                "tv_可爱":"f92d20f76258bc5f33fc9d7c5e2a1d41fef19a7c.gif@48w_48h.webp",
                "tv_发财":"76131e52c9b033681b4c896c6024d29ef7ec7ec2.gif@48w_48h.webp",
                "tv_生病":"beb94829fe04f1a41bd6ca611e1f6ca9ca169afa.gif@48w_48h.webp",
                "tv_流鼻血":"8ef473f74a849420da712487b2f56ecca1f695f5.gif@48w_48h.webp",
                "tv_尴尬":"e0b84ef5ee3e5b8978e584c7c5a6550c51d15f84.gif@48w_48h.webp",
                "tv_大佬":"14ca0c05382b8741940942b2430b7a8d55c02f7e.gif@48w_48h.webp",
                "tv_流泪":"7e71cde7858f0cd50d74b0264aa26db612a8a167.png@48w_48h.webp",
                "tv_冷漠":"b9cbc755c2b3ee43be07ca13de84e5b699a3f101.png@48w_48h.webp",
                "tv_皱眉":"72ccad6679fea0d14cce648b4d818e09b8ffea2d.png@48w_48h.webp",
                "tv_鬼脸":"0ffbbddf8a94d124ca2f54b360bbc04feb6bbfea.png@48w_48h.webp",
                "tv_调侃":"4bc022533ef31544ca0d72c12c808cf4a1cce3e3.png@48w_48h.webp",
                "tv_目瞪口呆":"0b8cb81a68de5d5365212c99375e7ace3e7891b7.png@48w_48h.webp",
            },

            master: "8c9b6d6637904da62d74d019cc6982de",
            friends: "0188229a9cfc284176ea9135cb9514cc",
            tagMeta: ["博主","友人","访客"],
            visitor: true // 阅读量统计
          }
        )
        new Valine(options);
        Fluid.utils.waitElementVisible('#valine .vcontent', () => {
          var imgSelector = '#valine .vcontent img:not(.vemoji)';
          Fluid.plugins.imageCaption(imgSelector);
          Fluid.plugins.fancyBox(imgSelector);
        })
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


    </article>
  


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      <!-- 文章页面 - 右侧目录 -->

  <aside class="sidebar" style="margin-left: -1rem">
    <!-- 文章页面 - 右侧目录上方 -->
<div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>



    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <!-- 博客 - 搜索框 -->
<div
  class="modal fade"
  id="modalSearch"
  tabindex="-1"
  role="dialog"
  aria-labelledby="ModalLabel"
  aria-hidden="true"
>
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">
          搜索
        </h4>
        <button
          type="button"
          id="local-search-close"
          class="close"
          data-dismiss="modal"
          aria-label="Close"
        >
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input
            type="text"
            id="local-search-input"
            class="form-control validate"
          />
          <label data-error="x" data-success="v" for="local-search-input"
            >关键词</label
          >
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
        <div class="modal fade" id="modalNotice" tabindex="-1" role="dialog" aria-hidden="true"
     style="font-family: 'Ma Shan Zheng', cursive; color: #ffffff;">
    <div class="modal-dialog modal-dialog-scrollable" role="document"
         style="font-family: 'Ma Shan Zheng', cursive;">
        <div class="modal-content" style="border-radius: 6px;">
            <!-- 公告头部 - 响应式设计 -->
            <div class="modal-header text-center"
                 style="padding: 1rem 1.5rem;border-bottom: 1px solid rgba(255,255,255,0.2)">
                <h4 class="modal-title w-100 font-weight-bold"
                    style="font-family: 'Microsoft YaHei', sans-serif;letter-spacing: 1px;text-shadow: 1px 1px 2px rgba(0,0,0,0.2);color: #ffffff;
                           font-size: 1.5rem; /* 默认PC端大小 */
                           /* 移动端适配 */
                           @media (max-width: 768px) {
                               font-size: 1.2rem;
                           }">
                    <div class="notice-title">
                        <i class="fas fa-bullhorn mr-2"> 围栏告示</i>
                    </div>
                    <small style="display: block; font-family: 'STKaiti', serif; font-size: 0.6em; color: #a0a0a0; margin-top: 3px;">
                        旧梦轻拾 · 谨识
                    </small>
                </h4>
            </div>

            <!-- 公告内容区 - 响应式设计 -->
            <div class="modal-body"
                 style="padding: 2rem; /* PC端 */
                        max-height: 70vh;
                        overflow-y: auto;
                        /* 移动端适配 */
                        @media (max-width: 768px) {
                            padding: 1rem;
                            max-height: 60vh;
                        }">
                <!-- 图片容器（响应式设计） -->
                <!--                <div class="announcement-hero"-->
                <!--                     style="margin-bottom: 2rem; /* PC端 */-->
                <!--                            /* 移动端适配 */-->
                <!--                            @media (max-width: 768px) {-->
                <!--                                margin-bottom: 1rem;-->
                <!--                            }">-->
                <!--                    <img src="http://blog.memory-life.icu/%E3%80%90%E5%93%B2%E9%A3%8E%E5%A3%81%E7%BA%B8%E3%80%91%E5%8A%A8%E6%BC%AB-%E5%A4%95%E9%98%B3%E9%93%81%E8%BD%A8.jpg"-->
                <!--                         alt="时光溯洄题图"-->
                <!--                         style="width: 100%; -->
                <!--                                max-height: 400px; /* PC端 */-->
                <!--                                object-fit: cover;-->
                <!--                                border-radius: 4px; -->
                <!--                                box-shadow: 0 2px 12px rgba(0,0,0,0.1);-->
                <!--                                /* 移动端适配 */-->
                <!--                                @media (max-width: 768px) {-->
                <!--                                    max-height: 30vh;-->
                <!--                                }"-->
                <!--                         loading="lazy">-->
                <!--                </div>-->

                <!-- 静态公告列表 - 响应式设计 -->
                <div class="announcement-list">
                    <div class="announcement-item"
                         style="margin-bottom: 2rem; /* PC端 */
                                padding: 2rem;
                                background: rgba(255,255,255,0.05);
                                border-radius: 8px;
                                /* 移动端适配 */
                                @media (max-width: 768px) {
                                    margin-bottom: 1rem;
                                    padding: 1rem;
                                }">
                        <h2 style="color: #d38532;
                                  font-weight: 600;
                                  font-size: 1.5rem; /* PC端 */
                                  margin-bottom: 1.2rem;
                                  letter-spacing: 0.5px;
                                  /* 移动端适配 */
                                  @media (max-width: 768px) {
                                      font-size: 1.2rem;
                                      margin-bottom: 1rem;
                                  }">
                            <i class="fas fa-calendar-check mr-2"></i>时光溯洄
                            <small style="display: block; font-size: 0.6em; color: #b8b8b8;text-align: right;">——
                                晨昏往事</small>
                        </h2>
                        <div style="color: #e0e0e0;
                                  line-height: 1.8; /* PC端 */
                                  font-size: 1.05rem;
                                  letter-spacing: 0.3px;
                                  /* 移动端适配 */
                                  @media (max-width: 768px) {
                                      line-height: 1.6;
                                      font-size: 0.95rem;
                                  }">
                            <!-- 内容保持不变 -->
                            <p style="margin-bottom: 1rem; text-indent: 2em;">你好。</p>
                            <!-- 其余段落内容... -->
                            <p style="margin-bottom: 1rem; text-indent: 2em;">
                                建站后的第813天，在百忙之中总算又能抽出时间来，对整个博客站点功能做整体的规划及优化完善。</p>
                            <p style="margin-bottom: 1rem; text-indent: 2em;">
                                在刚刚过去的几年时间里，往事皆以笔墨挥毫于时光素笺之上，数百天如一日，故事的书写从未间断过。</p>
                            <p style="margin-bottom: 1rem; text-indent: 2em; font-style: italic; color: #b8b8b8;">
                                时光悠悠，日月如流，过往的蹉跎岁月总在不经意间在心间回眸。</p>
                            <p style="margin-bottom: 1rem; text-indent: 2em; font-weight: 500; color: #ffffff;">
                                俯仰之间，轻舟已过万重山。</p>
                            <p style="margin-bottom: 1rem; text-indent: 2em; font-weight: 500; color: #ffffff;">
                                蹉跎之处，往事皆成云烟散。</p>
                            <p style="margin-bottom: 1rem; text-indent: 2em;">
                                这几年的时光过得太快了，好像过去这段岁月里的所有事情都发生在一瞬间。</p>
                            <p style="margin-bottom: 1rem; text-indent: 2em;">
                                这几年的时光同样太久了，久到那些时日里仿佛囊括了自己的整个前半生。</p>
                            <p style="margin-bottom: 0; text-align: right; font-size: 0.95rem; color: #a0a0a0;">——
                                八百余个昼夜，当时只道是地久天长，如今回望，不过浮光掠影间的一瞬。</p>
                        </div>
                    </div>

                    <!-- 第二个公告项 - 响应式设计 -->
                    <div class="announcement-item"
                         style="margin-bottom: 2rem; /* PC端 */
                                padding: 2rem;
                                background: rgba(255,255,255,0.05);
                                border-radius: 8px;
                                /* 移动端适配 */
                                @media (max-width: 768px) {
                                    margin-bottom: 1rem;
                                    padding: 1rem;
                                }">
                        <h2 style="color: #6cc70b;
                                  font-weight: 600;
                                  font-size: 1.5rem; /* PC端 */
                                  margin-bottom: 1.2rem;
                                  letter-spacing: 0.5px;
                                  /* 移动端适配 */
                                  @media (max-width: 768px) {
                                      font-size: 1.2rem;
                                      margin-bottom: 1rem;
                                  }">
                            <i class="fas fa-book-open mr-2"></i>墨痕新注
                            <small style="display: block; font-size: 0.6em; color: #b8b8b8;text-align: right;">——
                                待起之章</small>
                        </h2>
                        <div style="color: #e0e0e0;
                                  line-height: 1.8; /* PC端 */
                                  font-size: 1.05rem;
                                  letter-spacing: 0.3px;
                                  /* 移动端适配 */
                                  @media (max-width: 768px) {
                                      line-height: 1.6;
                                      font-size: 0.95rem;
                                  }">
                            <!-- 列表内容 - 响应式设计 -->
                            <ul style="padding-left: 1.8rem; /* PC端 */
                                      margin-bottom: 1.5rem;
                                      /* 移动端适配 */
                                      @media (max-width: 768px) {
                                          padding-left: 1.5rem;
                                          margin-bottom: 1.2rem;
                                      }">
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">溯源计划：</span>新增博文"溯源计划"，旨在用先进的数字技术留住过去的旧时光，让家族的记忆在数字云端生长发芽，全站博文数量已达90+。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">围栏告示：</span>自去年夏天站点新增了“评论回复”功能后，至今时隔十余月，在芒种前夕本站久违地上线“围栏告示”功能，本公告栏会不定时更新，持续跟进记录最新站点功能调整日志，更多精彩内容请敬请期待。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">图片查看：</span>最近几周时间里，考虑到图文流量费用收取问题，暂时关闭了七牛云对象存储私有空间访问权限，故博文内的图文无法正常预览，择日考虑开启访问权限。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">壁纸下载：</span>后续计划实现壁纸下载功能，均为个人收集的共150+超高分辨率精美壁纸，提供在线预览以及下载功能。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">阅读体验：</span>规划完善文章内分页功能，并提供“最近更新”的文章列表，计划收录更新率较高的文章，譬如：阳台日记、叙事之外、岁月如歌、游戏人生等等，尽可能多的提升在线浏览和阅读体验。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">友链完善：</span>持续优化完善友链页面，整理归档个人常用的高质量网站合集，无偿分享给有缘人。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">音乐餐厅：</span>历经十余小时不间断调研和尝试，本站成功上线”音乐餐厅”功能，目前仅收录了个人在QQ音乐平台积累的两份歌单，再匆忙也要记得点播一首喜欢的音乐，没有音乐熏陶的心灵终究是充满缺憾的。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">三言两语：</span>每张照片都是时光的便签，随手一贴就记下了那天，本站结合Mamos实现并注入留言板功能，随缘记录那些藏在照片背后的故事。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">旧梦轻拾：</span>更新全站博客文章所属分类，共设有代码锋芒、部署之道、旧梦轻拾、人间片刻等十余种分类。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">方寸之间：</span>博客应用版发布，更便捷的阅读体验来了！现已正式推出独立的桌面应用程序与移动端应用程序，暂时通过网盘和代码库提供安装包。
                                </li>
                                <p style="margin-bottom: 0; text-align: right; font-size: 0.9rem; color: #8a8a8a;">
                                    此公告最后更新于：<span style="color: #6cc70b;">2025/09/30晚</span>
                                </p>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 公告页脚 - 响应式设计 -->
            <div class="modal-footer"
                 style="border-top: 1px solid rgba(255,255,255,0.2);
                        padding: 1rem 1.5rem; /* PC端 */
                        justify-content: space-between;
                        /* 移动端适配 */
                        @media (max-width: 768px) {
                            padding: 0.8rem;
                        }">
                <small style="color: #ffffff;
                            font-size: 0.9rem; /* PC端 */
                            /* 移动端适配 */
                            @media (max-width: 768px) {
                                font-size: 0.8rem;
                            }">
                    <i class="iconfont icon-pen"></i>
                    <i class="fas fa-info-circle mr-1"></i>芒种前夕 · 旅途第813天
                    · 2025/05/28
                </small>
                <button id="confirm-btn" type="button" class="btn btn-sm" data-dismiss="modal"
                        style="background: #a0a0a0;
                               color: #ffffff;
                               border-radius: 4px;
                               padding: 0.5rem 1.2rem; /* PC端 */
                               border: none;
                               font-size: 0.9rem;
                               /* 移动端适配 */
                               @media (max-width: 768px) {
                                   padding: 0.3rem 0.8rem;
                                   font-size: 0.85rem;
                               }">
                    <i class="fas fa-check mr-1" style="color: #ffffff;">心已阅</i>
                </button>
            </div>
        </div>
    </div>
</div>

<style>
  .notice-title {
    display: flex;
    align-items: center;
    white-space: nowrap;
  }

  .notice-title:before,
  .notice-title:after {
    content: "";
    flex: 1;
    height: 1px;
    background: #ddd; /* 横线颜色 */
    margin: 0 10px; /* 横线与文字的间距 */
  }
</style>


<style>
  /* 响应式模态框宽度 */
  @media (min-width: 992px) {
    #modalNotice .modal-dialog {
      max-width: 800px;
    }
  }

  @media (max-width: 991px) {
    #modalNotice .modal-dialog {
      margin: 0.5rem auto;
    }
  }
</style>

<script>
  // 页面加载完成后执行
  document.addEventListener('DOMContentLoaded', function () {
    // 检查是否首次访问
    if (!localStorage.getItem('hasShownPopup')) {
      // 动态加载notice.ejs内容
      fetch('_partials/notice.ejs')  // 替换为实际路径
        .then(response => response.text())
        .then(html => {
          // 插入到页面body末尾
          document.body.insertAdjacentHTML('beforeend', html);

          // 手动初始化Bootstrap模态框
          $('#modalNotice').modal('show');

          // 标记为已显示
          localStorage.setItem('hasShownPopup', 'true');

          // 监听关闭事件
          $('#modalNotice').on('hidden.bs.modal', function () {
            // 可选的后续处理
          });
        })
        .catch(error => {
          console.error('加载公告栏失败:', error);
          // 备用方案：显示简单弹窗
          const fallbackHTML = `
                <div class="modal-backdrop" style="/* 样式 */">
                    <div class="modal-content">/* 内容 */</div>
                </div>`;
          document.body.insertAdjacentHTML('beforeend', fallbackHTML);
        });
    }
  });
</script>

    

    
  </main>

  <footer>
    <!-- 博客 - 页脚 -->
<div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.fluid-dev.com/docs/guide/" target="_blank" rel="nofollow noopener"> <span>Memory | 个人文档站点</span> </a>
<i class="iconfont icon-love"></i> <a href="https://hexo.fluid-dev.com/docs/guide/" target="_blank" rel="nofollow noopener"> <span>配置指南 | Hexo Fluid 用户手册</span> </a> 
    </div>
  

  

  
    <!-- 备案信 ICP for China -->
    <div class="beian">
  <span>
    <a href="http://beian.miit.gov.cn/" target="_blank" rel="nofollow noopener">
      京ICP证123456号
    </a>
  </span>
  
    
      <span>
        <a
          href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=12345678"
          rel="nofollow noopener"
          class="beian-police"
          target="_blank"
        >
          
            <span style="visibility: hidden; width: 0">|</span>
            <img src="/blog/img/police_beian.png" alt="police-icon"/>
          
          <span>京公网安备12345678号</span>
        </a>
      </span>
    
  
</div>

  

  

</div>

<!-- 评论框美化 -->
<style>
    #comments .veditor{
        min-height: 20vh;
        background-image: url(http://blog.memory-life.icu/pathway0716.jpg);
        background-size: contain;
        background-repeat: no-repeat;
        background-position: right;
        background-color: rgba(255,255,255,0);
        resize: none;}
</style>

<script>
    //   自定义邮箱审核规则
    document.body.addEventListener('click', function(e) {
        if (e.target.classList.contains('vsubmit')) {
            const email = document.querySelector('input[type=email]');
            const nick = document.querySelector('input[name=nick]');
            const reg = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
            if (!email.value || !nick.value || !reg.test(email.value)) {
                const str = `<div class="valert text-center"><div class="vtext">请填写正确的昵称和邮箱！</div></div>`;
                const vmark = document.querySelector('.vmark');
                vmark.innerHTML = str;
                vmark.style.display = 'block';
                setTimeout(function() {
                    vmark.style.display = 'none';
                    vmark.innerHTML = '';
                }, 2500);
            }
        }
    })
</script>



  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/blog/js/events.js" ></script>
<script  src="/blog/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>







  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/blog/js/local-search.js" ></script>

  <script defer src="/blog/js/leancloud.js" ></script>




    
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>



<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/blog/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
